#K82992. Tic Tac Toe Winning Move

    ID: 36098 Type: Default 1000ms 256MiB

Tic Tac Toe Winning Move

Tic Tac Toe Winning Move

You are given a Tic Tac Toe board of size \(n \times n\) where each cell contains one of the characters 'A', 'B', or '.'. The character '.' denotes an empty space. Your task is to determine whether there exists a move such that if a player (either 'A' or 'B') places their marker in the only empty spot in a line (row, column, or one of the two main diagonals) that already contains exactly two of their markers, the player wins by forming a line of exactly three markers. Note that the winning move should complete the line to have exactly three markers.

Example:

Input:
3
A B .
A B .
. . B

Output: True

</p>

In the above example, if either player places their marker in the empty cell of the second column, they complete a column with exactly two markers already present and one empty slot, leading to a win.

inputFormat

The input is read from stdin and has the following format:

  • The first line contains an integer \(n\) (in this problem, \(n=3\) for a standard Tic Tac Toe board).
  • The following \(n\) lines each contain \(n\) characters separated by spaces. Each character is either 'A', 'B', or '.', representing the state of a cell in the board.

outputFormat

Output a single line to stdout containing True if there exists a winning move according to the rules described, otherwise output False.

## sample
3
A B .
A B .
. . B
True