#B4186. Hex Game Outcome

    ID: 11843 Type: Default 1000ms 256MiB

Hex Game Outcome

Hex Game Outcome

Jimmy and Chen are playing a strange board game called Hex. The board is an $N \times N$ grid of hexagons. Two hexagons are connected if they share a common edge. For a non-boundary cell $(i,j)$, its six neighbors are given by: $(i, j+1)$, $(i, j-1)$, $(i+1, j)$, $(i+1, j-1)$, $(i-1, j)$, and $(i-1, j+1)$. On the boundary, only the in-bound neighbors are considered.

The game is played by two players taking turns. Jimmy (who plays first) places a red stone on an empty cell, and then Chen places a blue stone. If, at the end of the game, Jimmy has connected the top boundary to the bottom boundary with a continuous chain of red stones, then Jimmy wins; if Chen has connected the left boundary to the right boundary with blue stones, then Chen wins. It is guaranteed that both players cannot win simultaneously.

inputFormat

The first line contains an integer $T$, the number of test cases. For each test case, the first line contains an integer $N$ ($1 \leq N \leq 100$), the size of the board. The next $N$ lines each contain a string of length $N$ consisting only of the characters R (red stone), B (blue stone), and . (empty cell).

outputFormat

For each test case, output a single line containing Jimmy if Jimmy wins, Chen if Chen wins, or Not finished if neither has connected their respective boundaries.

sample

1
3
R..
RR.
.R.
Jimmy