spoj#OVOXO. Tic-tac-toe 3

Tic-tac-toe 3

Bored to death working at the Byteland Office...your colleagues have resorted to game of crosses Xs and naughtd Os or Tic-tac-toe. One of them keeps on losing and is tired of the jokes. He plans to have an Android app in his phone to help him out. He is your good friend and seeks your assistance. "Treat at ANC is guaranteed", he says.

He also is very frugal when it comes to memory usage. So please don't write a long if else chain...cause you have to do the task within 999 bytes

Input

An integer T - the number of test cases. (T<1000). T test cases follow.

Each test case comprises 3 strings each separated by newline and containing exactly 3 characters(either 'X','O' or '_') per line. An empty line follows each test case. Each input position is guaranteed to be a valid tic tac toe position such that the game is still not over.

Output

For each test case print "WON" if it is a sure shot winning position. Else print "CONTINUE". Then output the game after having made your move. If more than one move are equally good try playing the move on the first empty spot.

Example

Input:

2
OOX
OX_
__X

XX_ XOO O

Output:

WON
OOX
OXX
__X
WON
XXX
XOO
_O_

Info

1) iguaranteed always to be X's move (it is the standard) and whose move it currently is can be computed... 
2) winning position is meant for the current player 
3) winning in lesser number of moves is better and drawing is better than losing as in general AI 
4) you need to print the board as it looks after making the best move 
5) print WIN if the current player can win in the case when both players play optimally from here on... 
__X