#K66912. Taco Game Outcome

    ID: 32526 Type: Default 1000ms 256MiB

Taco Game Outcome

Taco Game Outcome

You are given an n x n grid representing a game played by two players: Player A and Player B. Each cell in the grid is either marked as 'A', 'B', or '.' (empty). A player wins if they fill an entire row, column, or one of the two diagonals with their symbol. Specifically, the winning conditions are:

  • For any row i, if grid[i][j] = X for all j (where X is either 'A' or 'B'), then player X wins.
  • For any column j, if grid[i][j] = X for all i, then player X wins.
  • For the main diagonal, if grid[i][i] = X for all i, then player X wins.
  • For the anti-diagonal, if grid[i][n-i-1] = X for all i, then player X wins.

If both players do not satisfy any winning condition and the grid is completely filled with 'A' or 'B', the game is a Draw. If there are still empty cells ('.') and no winning condition is met, the game is Pending.

You will be given multiple test cases. For each test case, determine whether Player A wins, Player B wins, the game results in a Draw, or if it is still Pending.

inputFormat

The first line contains an integer t representing the number of test cases. For each test case, the following input is provided:

  • An integer n representing the size of the grid.
  • n lines follow, each containing a string of length n consisting of the characters 'A', 'B', or '.'.

outputFormat

For each test case, output a single line containing one of the following: "A", "B", "Draw", or "Pending", indicating the outcome of the game for that test case.

## sample
4
3
A.A
BBB
...
3
A..
ABA
A.B
3
...
.A.
...
3
AAB
BBA
ABA
B

A Pending Draw

</p>