Pawns

No attempts yetTime limit1sMemory limit256 MB

Problem

Carl and Nathan find chess far too easy, so they invented a game of their own.

The game is played on a board with nn rows and mm columns. At the start each column holds one white pawn and one black pawn, and in every column the white pawn is on a lower square than the black pawn. White moves the white pawns and Black moves the black pawns. White goes first, and the players then take turns.

A move takes one of your own pawns one square forward, and that square must be empty. Forward means toward the opponent, so white pawns move up and black pawns move down. A pawn on its own first rank, meaning a white pawn on the bottom row or a black pawn on the top row, may move two squares forward instead. In that case the square it passes over and the square it lands on must both be empty. Unlike ordinary chess, pawns are never captured and never change column.

So a white pawn on the bottom row with two empty squares above it has two moves, one square up and two squares up. A pawn with an occupied square directly in front of it has no move at all.

Play continues until the two pawns of every column stand next to each other and neither player can move. The game ends there, and the player who made the last move wins.

Both players play optimally. Determine who wins.

Input

The first line has the number of test cases, a positive integer at most 100. Each test case is given as follows.

  • One line with the number of rows nn and the number of columns mm of the board (3n203 \le n \le 20, 1m201 \le m \le 20).
  • nn lines of mm characters each with the starting position, from the top row to the bottom row. W is a white pawn, B is a black pawn, . is an empty square. Each column holds exactly one W and exactly one B, and the W is below the B.

White has at least one move in every test case.

Output

Print one line per test case: White wins if White wins with optimal play, or Black wins if Black has a winning strategy.