Tom has developed a special kind of puzzle: it involves a whole bunch of identical puzzle
pieces. The pieces have the shape of three adjoint squares in an L-shape. The corner square is
black, the two adjacent squares are white.
On the first line a positive integer: the number of test cases, at most 100. After that per test
case:
1. one line with two integers n and m (1 ≤ n,m ≤ 500): the height and width of the grid
containing the pattern, respectively.
2. n lines, each containing m characters, denoting the grid. Each character is ‘B’, ‘W’, or ‘.’,
indicating a black, white or empty square respectively.
The grid contains at least one black or white square.
Per test case:
one line with either “YES” or “NO”, indicating whether or not it is possible to construct
the pattern with the puzzle pieces. You may assume that there is an infinite supply of
pieces.
2 3 4 BWW. WWBW ..WB 3 3 W.. BW. WBW
YES NO
Migrated from old NTUJ.
NWERC2011
No. | Testdata Range | Score |
---|