eolymp
bolt
Спробуйте наш новий інтерфейс для відправки розв'язків
Задачі

Let the Wookiee Win!

Let the Wookiee Win!

Ліміт часу 3 секунди
Ліміт використання пам'яті 256 MiB

You are playing against Chewbacca in a tough battle of Galactic Tic-Tac-Toe, which is just like simple Tic-Tac-Toe except that the playing board is 5×5 and the goal is to get 4 in a row. In response to a brilliant move, Chewbacca protests loudly and plays his next move, setting you up to win. However, before you can claim victory, Han Solo takes this opportunity to warn you that it's not wise to upset a Wookiee. After all, they're known to pull people's arms out of their sockets when they lose. Wisely, you decide on a new strategy: Let the Wookiee win!

Вхідні дані

Input consists of a series of 5×5 playing boards, each separated by a blank line. Each square in a row is separated by a single space. You are 'O', Chewie is 'X', and empty squares are denoted by '*'. For each board, there is exactly one empty square that you can play that does not cause you to win and does not block any of Chewie's winning moves on his next turn. The final board is followed immediately by the word "Finished" on the next line.

Вихідні дані

For each board, print a line consisting of the number of the square that you should play to avoid having your arms pulled out of their sockets. The numbering should conform to the following table.

Приклад

Вхідні дані #1
X O * X X
O O X X *
O O * X X
O X O O X
X O O X O

X X X * O
O * * O X
O O X * X
O * X X O
* X O O O
Finished
Вихідні дані #1
3
17
Джерело ACM ICPC Regionals 2009: North America - Pacific Northwest