#P1838. 三子棋I

三子棋I

Description

xiaoa and uim enjoy playing tic-tac-toe against each other. Tic-tac-toe is played on a 3×33 \times 3 grid by placing O and X; whoever connects 33 in a line wins.

Since xiaoa is less skilled, uim always lets him move first.

We use 99 digits to represent the board positions:

$$\def\arraystretch{1.5} \begin{array}{|c|c|c|}\hline 1 & 2 & 3 \\\hline 4 & 5 & 6 \\\hline 7 & 8 & 9 \\\hline \end{array}$$

All recorded games are already finished: either one player wins, or it is a draw.

Today, they played all afternoon. To improve his skills, xiaoa recorded many game logs. He wants to know who won when a game ends.

Input Format

One line, a string of digits indicating the move positions. xiaoa always moves first.

Output Format

One line. If xiaoa wins, output xiaoa wins.. If uim wins, output uim wins.. If it is a draw, output drew..

5237649

xiaoa wins.

539128647
drew.

Hint

Translated by ChatGPT 5