Hide

Problem L
Distance Game

Alice and Bob are playing a game on an $n$ by $m$ grid of black and white squares. On each player’s turn, they select any white square $(i, j)$, and an integer $k\ge 0$ such that all squares within a Manhattan distance of $k$ of $(i, j)$ are white (and within the bounds of the grid), and color all of those squares black.

The Manhattan distance between two positions $(i_1, j_1)$ and $(i_2, j_2)$ is $|i_1 - i_2| + |j_1 - j_2|$.

For example, here is one possible initial state of the grid, and two possible moves that a player can make. Notice that for each move, all squares within Manhattan distance $k$ of $(i, j)$ must be white and within the bounds of the grid:

\includegraphics[scale=0.5]{distancegame.png}

The player who colors the last square black wins. Given that Alice goes first, who will win if both players play optimally?

Input

The first line of the input contains a single integer $t$ ($1 \le t \le 10^4$) —the number of test cases. The description of the test cases follows.

The first line of each test case contains two integers $n$ and $m$ ($1\le n, m \le 500$) —the number of rows and columns in the grid, respectively.

The $i$-th of the next $n$ lines of each test case consist of $m$ characters each —the initial state of the squares in the $i$-th row. These characters will either be $B$, indicating a black square, or $W$, indicating a white square.

It is guaranteed that the sum of $nm$ over all test cases does not exceed $3\cdot 10^5$.

Output

For each test case, output “Alice” (without quotes) if Alice will win if both players play optimally, and “Bob” otherwise.

Sample Input 1 Sample Output 1
7
6 8
BBBWWWWB
WBWBWWWB
WWWWWWWW
BBWWWWWB
WBBWBWWW
WBWBBWWB
1 1
W
1 1
B
3 3
WWW
WWW
WWW
4 5
WBWBW
BWBWB
WBWBW
BWBWB
10 11
WBBBWWWWWWW
WWWWWWWBWWW
BWWWWWWWBBW
WBBWBWWWWWB
WWBWBBWWWBW
WWWWWWWWBWW
WWWWWWBWWBW
BBWWWBWWWWW
WWBWBWWWBWW
WWWBWWBWWWB
8 3
BWW
BWB
BWW
WBW
WWW
WWW
BWW
BBW
Alice
Alice
Bob
Alice
Bob
Alice
Bob

Please log in to submit a solution to this problem

Log in