SOHA and TARA are playing Game of Blocks. ‘Game of Blocks’ is a two player game played on a 4x4 board. At the start of the game, each cell contains a piece colored red or blue. The two players make moves alternately – SOHA, being player 1, makes the first move. In each move, a player chooses a colored cell (that is a cell with a blue or a red piece in it). After making a move, all the reachable cells from that selected cell vanishes. Two cells are reachable if you can start from one and end on the other by making moves in the direction up, down, left or right and all the pieces in the path has the same color. After each move, all the pieces will come down to fill the empty spaces.
Say, SOHA makes a move by selecting the cell at row 2 and column 3 or in other words cell (2, 3). The diagrams below shows what happens to the pieces after the move is made.
The first line of input is an integer T that indicates the number of test cases. Each case consists of 4 lines with 4 characters in each. The characters are ‘B’ or ‘R’ to indicate blue and red pieces respectively. There is a blank line after each case.
For each case, output the case number first. If SOHA can win the game, print “win X”, otherwise print “loss X” where X indicates the total number of moves before all the pieces vanishes.
3 BBBB BBBB BBBB BBBB BBBB RRRR BBBB RRRR BRBR BRBR BRBR BRBR
Case 1: win 1 Case 2: win 3 Case 3: loss 4
Migrated from old NTUJ.
icpc regional 2009, dhaka site
No. | Testdata Range | Score |
---|