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 k0 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 (i1,j1) and (i2,j2) is |i1i2|+|j1j2|.

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 (1t104) —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 (1n,m500) —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 3105.

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
Hide

Please log in to submit a solution to this problem

Log in