Weiqi

Weiqi is an intellective game from ancient China, which was said that come from simulation of wars on table in legend. People play Weiqi on a board with 19 horizontal lines and 19 vertical lines intersected by each other. Two players put black or white cobble onto one of 361 intersect points on the board one by one. The player which have control of more intersect points at last win the game. There are several rules of Weiqi: • There are no black or white cobbles on the board before the game begins. Black select one intersect point on the board to put on his cobble first, then white, one by one, and so on. Cobble put on point that already put cobble before is invalid, the player which put that cobble on will be considered as pass. Player put one cobble on calls one turn. Player can also chose pass when in his turn. • Any cobbles that conjoints to other on vertical or horizontal lines calls one block of cobbles. A block of cobbles calls “dead block” if there are no empty intersect point but cobbles in same color or other color conjoints up, down, left, or right to every one cobble of the block. Any cobbles of a dead block should be taken away from the board. All black cobbles are dead ones in figure below: • Cobble put on the board then a block of cobbles in the other color becomes “dead block” and be taken away from the board calls “beat”. One intersect point calls “taboo point” if cobble put on will make one block of cobbles in same color become dead block and can’t beat any cobbles in the other color, or status of the board after take away any dead blocks same as that before opponent player’s last turn. The cobble must be take away from the board and resume the status before that putting, then the player put that cobble is considered to chose pass. ‘X’ in figure below shows taboo points:

2/4 • It calls “same loop” if the status of board after one’s valid put is same to before and there are no any ‘pass” in that loop. The game is “tie” if appears “same loop” and players replay the game then. There is a sample of “three conflicts loop” (one kind of “same loop”) in figure below. The problem request you to write a program that read data of two players’ playing and simlulate the course of the game Weiqi. Input There are data groups of several games in one input file. Every data group consists of a sequence of integer a, b (1 ≤ a,b ≤ 19) pairs. One integer pair a, b indicates the intersect point that the player want put his cobble on, which a indicates the horizontal line number through the point (from 1 to 19 indicates top to bottom) and b indicates the number of vertical line through the point (from 1 to 19 indicates left to right); a = b = 0 indicates that pass by the player. The first pair indicates the point that black cobble put, next white, one by one, and so on. The data after last turn of a tie game will auto begins a new game, however, black will put first cobble on the board even the last turn of tie game is also played by black. The game is over while black and white pass by player too. The input is ended by a game with first pair that a = b = −1. Output Program should output ‘Game #x’ in a single line where x is an integer from 1. You should output information below in a single line while one player pass his turn: Turn XXX PLAYER pass (taboo point A,B) Turn XXX PLAYER pass (invalid put A,B) Turn XXX P LAY ER pass (by player) while point A,B is taboo point; while PLAYER can’t put his cobble on point A,B; while P LAY ER chosed pass. where PLAYER is ‘white’ or ‘black’; A,B is the intersect point that player want to put his cobble on; XXX means number of turns when the player put his cobble. Your program should output ‘Total XXX turn(s)’ in a single line first, where XXX is the total number of turns of the game while the game is over or tie; your program should plus one line with ‘(Tie)’ if the game is tie. Then output the status of board which should consists of 19 lines, each line consists 19 characters, indicates status of 361 intersect points, where ‘e’ indicates black cobble; ‘o’ indicates white cobble and ‘+’ indicates empty point. Output should be left to right, top to bottom corresponds to the board. Your program must output one empty line after any case and no more empty line or empty space in line.

3/4 Sample Input 16 4 16 3 17 3 17 2 18 4 18 3 17 1 18 2 18 1 19 1 16 1 17 4 17 5 18 5 16 2 19 4 15 3 19 6 18 6 19 3 17 3 16 3 17 6 16 3 19 5 18 4 19 7 17 7 19 5 16 5 17 3 19 6 19 2 16 3 19 5 19 1 16 4 4 16 4 4 16 16 10 4 17 6 17 8 18 4 18 3 17 3 17 4 0 0 18 5 17 5 19 4 18 4 16 7 15 5 16 5 18 6 16 6 18 8 18 7 19 7 19 6 17 7 18 7 0 0 0 0 -1 -1 Sample Output Game #1 Turn 22 white pass (taboo point 16,3) Turn 25 black pass (taboo point 19,5) Total 36 turn(s) (Tie) +++++++++++++++++++ +++++++++++++++++++ +++++++++++++++++++ +++++++++++++++++++ +++++++++++++++++++ +++++++++++++++++++ +++++++++++++++++++ +++++++++++++++++++ +++++++++++++++++++ +++++++++++++++++++ +++++++++++++++++++ +++++++++++++++++++ +++++++++++++++++++ +++++++++++++++++++ ++e++++++++++++++++ eeoeo++++++++++++++ eo+oeeo++++++++++++ eooooe+++++++++++++ o+ooe+e++++++++++++ Turn 12 white pass (by player) Turn 16 white pass (taboo point 18,4) Turn 28 white pass (by player) Turn 29 black pass (by player) Total 29 turn(s) +++++++++++++++++++ +++++++++++++++++++ +++++++++++++++++++ +++e+++++++++++o+++ +++++++++++++++++++ +++++++++++++++++++ +++++++++++++++++++ +++++++++++++++++++ +++++++++++++++++++ +++e+++++++++++++++

4/4 +++++++++++++++++++ +++++++++++++++++++ +++++++++++++++++++ +++++++++++++++++++ ++++o++++++++++++++ +++eeee++++++++o+++ ++oe+++e+++++++++++ ++e+e+eo+++++++++++ +++e+eo++++++++++++