#P14017. [ICPC 2024 Nanjing R] 棋字井

[ICPC 2024 Nanjing R] 棋字井

Description

Alice and Bob are playing Toe-Tac-Tics on nn boards with 33 rows and 33 columns. Some cells on the boards are initially empty, while the others already contain some marks. Alice moves first, and they take turns to select a board and put their marks into an empty cell on that board. Alice's mark is x and Bob's mark is o.

Each player must make sure that no three same marks are in any row, column, or diagonal on any board after his/her move. The player who cannot make a valid move on their turn loses, and the other player wins.

Given the initial state of the nn boards, you need to determine who wins, assuming both players play optimally for victory.

Input Format

There are multiple test cases. The first line of the input contains an integer TT indicating the number of test cases. For each test case:

The first line contains an integer nn (1n1051 \le n \le 10^5), indicating the number of boards in the game.

Then nn boards of size 3×33 \times 3 follow. For each board:

  • There will first be an empty line if it is not the first board.
  • For the following three lines, the ii-th line contains a string si,1si,2si,3s_{i,1}s_{i,2}s_{i,3} of length 33 consisting of characters x, o, and ., describing a board of size 3×33 \times 3. Let (i,j)(i, j) be the cell on the ii-th row and the jj-th column. If si,j=s_{i, j} = x then cell (i,j)(i, j) contains a mark x; if si,j=s_{i, j} = o then cell (i,j)(i, j) contains a mark o; if si,j=s_{i, j} = . then cell (i,j)(i, j) is empty.

It is guaranteed that no three same marks are in any row, column, or diagonal on any board. It is also guaranteed that the sum of nn for all test cases does not exceed 10510^5.

Output Format

For each test case, output Alice\texttt{Alice} if Alice wins the game, or Bob\texttt{Bob} if Bob wins the game.

4
1
...
...
...
1
...
oo.
oo.
2
...
oo.
oo.

...
xx.
xx.
2
..x
xo.
...

xo.
o..
.x.
Alice
Alice
Bob
Bob