시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 377 123 104 32.704%

문제

상근(Albert), 민혁(Barbara), 선영(Casper), 창영(Dinko), 현진(Eustahije)이가 마라톤 틱택토 게임을 하려고 한다. 이 게임은 N×N 보드에서 진행한다.

맨 처음에 보드의 모든 칸은 비어있다. 플레이어는 턴을 번갈아가면서 자신의 영어 이름의 첫 글자를 빈 칸에 적는다. (두 사람의 영어 이름의 첫 글자가 같은 경우는 없다)

게임은 세 글자가 행, 열, 또는 대각선으로 연속할 때, 그 플레이어가 승리하며, 게임이 끝나게 된다.

보드판의 상태가 주어졌을 때, 게임이 끝났는지 아닌지를 결정하고, 끝났다면 승자가 누구인지 구하는 프로그램을 작성하시오.

입력

첫째 줄에 보드판의 크기 N이 주어진다. (1 ≤ N ≤ 30)

다음 N개 줄에는 보드판의 상태가 주어진다. '.'는 빈 칸을 나타낸다.

항상 승리한 사람이 많아야 한 명인 경우만 입력으로 주어진다. 

출력

첫째 줄에 게임이 끝났다면, 승리한 사람의 영어 이름의 첫 글자를 출력한다. 그렇지 않다면, "ongoing"을 출력한다. 게임을 승리한 사람이 없는데, 빈 칸이 없는 경우에도 ongoing을 출력해야 한다.

예제 입력 1

3
XOC
XOC
X..

예제 출력 1

X
W3sicHJvYmxlbV9pZCI6IjMwMjQiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWI5YzhcdWI3N2NcdWQxYTQgXHVkMmYxXHVkMGRkXHVkMWEwIiwiZGVzY3JpcHRpb24iOiI8cD5cdWMwYzFcdWFkZmMoQWxiZXJ0KSwgXHViYmZjXHVkNjAxKEJhcmJhcmEpLCBcdWMxMjBcdWM2MDEoQ2FzcGVyKSwgXHVjYzNkXHVjNjAxKERpbmtvKSwgXHVkNjA0XHVjOWM0KEV1c3RhaGlqZSlcdWM3NzRcdWFjMDAgXHViOWM4XHViNzdjXHVkMWE0IFx1ZDJmMVx1ZDBkZFx1ZDFhMCBcdWFjOGNcdWM3OD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