Abalone

Time Limit: 3000/1000 MS (Java/Others)

Memory Limit: 65536/32768 K (Java/Others)

Description

Abalone is a popular board game, the rules are as follow:
1.At first, two players each have 14 marbles, starting to play in turn.

2.For each turn, player must move a line of one, two or three adjacent marbles one space unless he couldn't move any marbles. The move can be either in-line (parallel to the line of marbles)

or broadside (not parallel to the line of marbles), as illustrated below.

3.A player can push their opponent′s marbles which are in an adjacent space to their own with an in-line move only. They can only push if the pushing line has more marbles than the pushed line (three can push two or one; two can push one). Marbles must be pushed into an open space or out of board(i.e. not blocked by a marble of either colour).

4.The winner is the first player to push six of the opponent's marbles off of the edge of the board.

Now, it's White player's turn to move, could White player win in this turn? If not, Black player moves, could Black player win in next turn no matter which move White player choose?

Input

The first line is a number T(1<=T<=30), which represents the number of case. The next T blocks follow each indicates a case.
A block has nine lines. They are the state of the situation.
'B' indicate the Black marble.
'W' indicate the White marble.
'.' indicate blank.
The number of marbles for each color will be no bigger than 14 and no smaller than 9.

Output

For each case, output the number of case with "White" or "Draw" or "Black".(as shown in the sample output)

Sample Input

3 B B B B B B B B B B B . . B B B . . . . . . . . . . . . . . . . . . . . . . . . . . . . . W W W . . W W W W W W W W W W W . . . . . B B B B B B . W B B B . . . . W . . . . . . . . W . . . . . . . . . . . . . . . . . . . . W W W W W W W W W W W . . . . . W B B B . . W W B B B . . W . W B B B . . W W W W . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Sample Output

Case 1: Draw Case 2: White Case 3: Black

Hint

lcy

Source

The 36th ACM/ICPC Asia Regional Fuzhou Site

提交代码