## GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

## [Solution] Lena and Matrix Codeforces Solution | Codeforces Problem Solution 2022

D. Lena and Matrix
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Lena is a beautiful girl who likes logical puzzles.

As a gift for her birthday, Lena got a matrix puzzle!

The matrix consists of $n$ rows and $m$ columns, and each cell is either black or white. The coordinates $\left(i,j\right)$ denote the cell which belongs to the $i$-th row and $j$-th column for every $1\le i\le n$ and $1\le j\le m$. To solve the puzzle, Lena has to choose a cell that minimizes the Manhattan distance to the farthest black cell from the chosen cell.

More formally, let there be $k\ge 1$ black cells in the matrix with coordinates $\left({x}_{i},{y}_{i}\right)$ for every $1\le i\le k$. Lena should choose a cell $\left(a,b\right)$ that minimizes

As Lena has no skill, she asked you for help. Will you tell her the optimal cell to choose?

Input

There are several test cases in the input data. The first line contains a single integer $t$ ($1\le t\le 10\phantom{\rule{thinmathspace}{0ex}}000$) — the number of test cases. This is followed by the test cases description.

The first line of each test case contains two integers $n$ and $m$ ($2\le n,m\le 1000$)  — the dimensions of the matrix.

The following $n$ lines contain $m$ characters each, each character is either 'W' or 'B'. The $j$-th character in the $i$-th of these lines is 'W' if the cell $\left(i,j\right)$ is white, and 'B' if the cell $\left(i,j\right)$ is black.

It is guaranteed that at least one black cell exists.

It is guaranteed that the sum of $n\cdot m$ does not exceed ${10}^{6}$.

Output

For each test case, output the optimal cell $\left(a,b\right)$ to choose. If multiple answers exist, output any.