LogiQuest

333. Tic-Tac-Toe Winner

EasySimulation

Given a finished or ongoing 3×3 board (X, O or .), print X or O if that player has three in a row, otherwise DRAW if the board is full, otherwise PENDING. At most one player has a line.

Input format

3 lines of 3 characters.

Output format

X, O, DRAW or PENDING

Example 1

Input

XOX
OXO
OOX

Output

X

Example 2

Input

XXX
OO.
...

Output

X

Constraints

Valid board.

Read input from standard input and print the answer to standard output. Your code is judged against 5 test cases, most of them hidden.

Loading the MyLoginn IDE…