atcoder#ABC229H. [ABC229H] Advance or Eat
[ABC229H] Advance or Eat
Score : points
Problem Statement
There is a grid with rows and columns, where each square has one white piece, one black piece, or nothing on it.
The square at the -th row from the top and -th column from the left is described by . If is W
, the square has a white piece; if is B
, it has a black piece; if is .
, it is empty.
Takahashi and Snuke will play a game, where the players take alternate turns, with Takahashi going first.
In Takahashi's turn, he does one of the following operations.
- Choose a white piece that can move one square up to an empty square, and move it one square up (see below).
- Eat a black piece of his choice.
In Snuke's turn, he does one of the following operations.
- Choose a black piece that can move one square up to an empty square, and move it one square up.
- Eat a white piece of his choice.
The player who becomes unable to do the operation loses the game. Which player will win when both players play optimally?
Here, moving a piece one square up means moving a piece at the -th row and -th column to the -th row and -th column. Note that this is the same for both players; they see the board from the same direction.
Constraints
- is an integer.
- is
W
,B
, or.
.
Input
Input is given from Standard Input in the following format:
Output
If Takahashi will win, print Takahashi
; if Snuke will win, print Snuke
.
3
BB.
.B.
...
Takahashi
If Takahashi eats the black piece at the -st row and -st columns, the board will become:
.B.
.B.
...
Then, Snuke cannot do an operation, making Takahashi win. Note that it is forbidden to move a piece out of the board or to a square occupied by another piece.
2
..
WW
Snuke
4
WWBW
WWWW
BWB.
BBBB
Snuke