Noughts and crosses (also known as tic-tac-toe) is a simple game for two players. The players take turns placing their own symbol on a 3×3 board; one player uses X and the other uses O. The aim is to be the first to line up three of your own symbols in a row — horizontally, vertically, or diagonally.

Given the record of the moves in one or more games, determine the result of each game.
You are given one or more games to replay, and you must decide the result of each one.
Each game is written on its own line. The line begins with the letter X or O, showing which player takes the first turn. That player makes the first move, and the two players then alternate turns.
After the leading letter come the moves, all on the same line and separated by spaces. Each move is a number from 1 to 9 that names the board square being marked, numbered as follows:
1 | 2 | 3
---------
4 | 5 | 6
---------
7 | 8 | 9

For example, Game 1 above is recorded as the leading letter X followed by the moves 1 5 9 7 3 6 2.
The input ends with a line containing only the character #. That line does not belong to any game and must not be processed.
For each game, print exactly one line.
X or O.Draw.A player wins the moment they complete a row of three; any moves listed after that on the same line do not change the result.