CF1985D.Manhattan Circle

传统题 时间 2000 ms 内存 256 MiB 4 尝试 1 已通过 1 标签

Manhattan Circle

Given a nn by mm grid consisting of '.' and '#' characters, there exists a whole manhattan circle on the grid. The top left corner of the grid has coordinates (1,1)(1,1), and the bottom right corner has coordinates (n,m)(n, m).

Point (a,ba, b) belongs to the manhattan circle centered at (h,kh, k) if ha+kb<r|h - a| + |k - b| \lt r, where rr is a positive constant.

On the grid, the set of points that are part of the manhattan circle is marked as '#'. Find the coordinates of the center of the circle.

Input

The first line contains tt (1t10001 \leq t \leq 1000)  — the number of test cases.

The first line of each test case contains nn and mm (1nm21051 \leq n \cdot m \leq 2 \cdot 10^5) — the height and width of the grid, respectively.

The next nn lines contains mm characters '.' or '#'. If the character is '#', then the point is part of the manhattan circle.

It is guaranteed the sum of nmn \cdot m over all test cases does not exceed 21052 \cdot 10^5, and there is a whole manhattan circle on the grid.

Output

For each test case, output the two integers, the coordinates of the center of the circle.

Samples

6
5 5
.....
.....
..#..
.....
.....
5 5
..#..
.###.
#####
.###.
..#..
5 6
......
......
.#....
###...
.#....
1 1
#
5 6
...#..
..###.
.#####
..###.
...#..
2 10
..........
...#......
3 3
3 3
4 2
1 1
3 4
2 4

在线编程 IDE

建议全屏模式获得最佳体验