Alice and Bob's Finished Board
Alice and Bob played tic-tac-toe on a huge n × n board. Alice wrote the letter A in the cells she took, Bob wrote B, and some cells were never claimed and are still empty. Nobody kept track of the game while it was going on, so now they stare at the finished board and argue about who actually won.
A player has a line if at least one of the following is filled entirely with their letter (no empty cells and no letters of the other player):
- one of the
nrows, - one of the
ncolumns, - the main diagonal, from the top-left corner to the bottom-right corner,
- the anti-diagonal, from the top-right corner to the bottom-left corner.
Other diagonals do not count. Given the board, find out who has a line. The board may not be one a real game could end with; just look at the marks as they are.
Input
The first line contains an integer n (1 ≤ n ≤ 1000), the size of the board.
Each of the next n lines contains a string of exactly n characters, each of them A, B or . (an empty cell). The i-th line describes the i-th row from the top.
Output
Print one word:
ALICEif only Alice has a line,BOBif only Bob has a line,BOTHif both of them have a line,NOBODYif neither of them has a line.
Notes
In the first example, Alice has the anti-diagonal (top-right to bottom-left). Bob's left column ends with Alice's A, so it is not his.
In the second example, Alice has the top row and Bob has the bottom row, so the answer is BOTH.
In the third example, the board is a single cell containing B: that one cell is a whole row by itself, so Bob has a line.