Sir Monocarp Hamilton is planning to paint his wall. The wall can be represented as a grid, consisting of $$$2$$$ rows and $$$m$$$ columns. Initially, the wall is completely white.
Monocarp wants to paint a black picture on the wall. In particular, he wants cell $$$(i, j)$$$ (the $$$j$$$-th cell in the $$$i$$$-th row) to be colored black, if $$$c_{i, j} =$$$ 'B', and to be left white, if $$$c_{i, j} =$$$ 'W'. Additionally, he wants each column to have at least one black cell, so, for each $$$j$$$, the following constraint is satisfied: $$$c_{1, j}$$$, $$$c_{2, j}$$$ or both of them will be equal to 'B'.
In order for the picture to turn out smooth, Monocarp wants to place down a paint brush in some cell $$$(x_1, y_1)$$$ and move it along the path $$$(x_1, y_1), (x_2, y_2), \dots, (x_k, y_k)$$$ so that:
Determine if Monocarp can paint the wall.
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases.
The first line of each testcase contains a single integer $$$m$$$ ($$$1 \le m \le 2 \cdot 10^5$$$) — the number of columns in the wall.
The $$$i$$$-th of the next two lines contains a string $$$c_i$$$, consisting of $$$m$$$ characters, where each character is either 'B' or 'W'. $$$c_{i, j}$$$ is 'B', if the cell $$$(i, j)$$$ should be colored black, and 'W', if the cell $$$(i, j)$$$ should be left white.
Additionally, for each $$$j$$$, the following constraint is satisfied: $$$c_{1, j}$$$, $$$c_{2, j}$$$ or both of them are equal to 'B'.
The sum of $$$m$$$ over all testcases doesn't exceed $$$2 \cdot 10^5$$$.
For each testcase, print "YES" if Monocarp can paint a wall. Otherwise, print "NO".
63WBBBBW1BB5BWBWBBBBBB2BWWB5BBBBWBWBBB6BWBBWBBBBBBB
YES YES NO NO NO YES
In the first testcase, Monocarp can follow a path $$$(2, 1)$$$, $$$(2, 2)$$$, $$$(1, 2)$$$, $$$(1, 3)$$$ with his brush. All black cells appear in the path exactly once, no white cells appear in the path.
In the second testcase, Monocarp can follow a path $$$(1, 1)$$$, $$$(2, 1)$$$.
In the third testcase:
Name |
---|