#P6369. Three in a Row on a Chessboard

    ID: 19585 Type: Default 1000ms 256MiB

Three in a Row on a Chessboard

Three in a Row on a Chessboard

Given an n×nn\times n chessboard, multiple players are playing a tic-tac-toe game. Each player uses a unique letter to mark their moves. In this game, a player wins if they can align 33 of their letters consecutively in a row, column, or diagonal.

Your task is to determine the winning player's letter from the current state of the chessboard.

inputFormat

The first line contains an integer nn, representing the size of the chessboard. The next nn lines each contain a string of length nn, representing the board's current state.

outputFormat

Output a single letter, which is the winner's letter. It is guaranteed that there is a winning move in the given board.

sample

3
XXX
OO.
OO.
X