题目描述
Problem Description
Given a $n \times n$ square board, several players play a game of tic-tac-toe.
The rules of tic-tac-toe are that each player takes turns writing a letter, with the same letter for the same player. A player wins when they form a continuous line of three of their letters either in a row, column, or diagonal.
Given the current state of the board, determine which player has won.
Input Format
The first line of input contains an integer $n$.
The next $n$ lines each contain $n$ characters, which can be uppercase letters or . (indicating no move has been made at that position).
Output Format
Output a single uppercase letter indicating the letter written by the winning player.
If no player has won, output ongoing.
It is guaranteed that at most one player has won.
Sample Input and Output
Sample Input #1
3
XOC
XOC
X..
Sample Output #1
X
Sample Input #2
4
....
..A.
AAB.
.B.B
Sample Output #2
ongoing
Sample Input #3
3
ABB
AAA
BBA
Sample Output #3
A
Notes
Data Constraints
For $100\%$ of the data, $1 \le n \le 30$.
Notes
This problem is translated from COCI2006-2007 CONTEST #6 T3 MARATON.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分