| 2024 China Collegiate Programming Contest (CCPC) Jinan Site (The 3rd Universal Cup. Stage 17: Jinan) |
|---|
| Finished |
The game is played on an $$$n\times m$$$ table. A cell has its color, which is one of red, blue, or white. Initially, cell $$$(a,b)$$$ is red, cell $$$(c,d)$$$ is blue (These two cells do not coincide), and others are white. We call $$$(a,b)$$$ and $$$(c,d)$$$ special cells and others nonspecial. During the game, the player can perform a certain operation, which consists of three steps:
In other words, in one operation, the player can color a nonspecial cell with the same color as its non-white neighboring cell. Note that a cell may be colored more than once, and the latest color will cover the earlier one.
The player can perform the operation any number of times and then stop the game. After that, the final configuration of the map table is printed.
Unfortunately, Generalissimo is full of cheats, and cheaters can color in any position at any time. In order to advocate Justice, you decide to write a judge program to determine whether the given configuration is possible to be a legal configuration in a normal game, or there must be a cheater.
The input consists of multiple test cases. The first line contains a single integer $$$T$$$ ($$$1\le T\le 10^4$$$) — the number of test cases. The description of the test cases follows.
The first line contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n,m \le 500$$$ and $$$2 \le n\cdot m$$$) — the number of rows and columns.
The second line contains four integers $$$a$$$, $$$b$$$, $$$c$$$, and $$$d$$$ ($$$1 \le a,c \le n$$$ and $$$1 \le b,d \le m$$$).
Each of the next $$$n$$$ lines contains $$$m$$$ characters. Each character is 'R', 'B', or '.', representing a red cell, a blue cell, and a white cell, respectively.
It is guaranteed that cell $$$(a,b)$$$ and $$$(c,d)$$$ do not coincide, and that the character on the $$$a$$$-th row $$$b$$$-th column and $$$c$$$-th row $$$d$$$-th column is 'R' and 'B', respectively.
It is guaranteed that the sum of $$$n \cdot m$$$ among $$$T$$$ test cases does not exceed $$$250\,000$$$.
For each test case, print "YES" (without quotes) if it is a legal configuration and "NO" (without quotes) otherwise.
You can print letters in any case (upper or lower).
43 31 1 1 2RBBRRRBBR6 61 1 6 6RRRRRRBBBBBRBRRRBRBRBBBRBRRRRRBBBBBB5 53 3 4 4BBR.BBBR.BRRR.B...BBBBBB.1 51 1 1 3RBBBR
YES YES NO NO
The following graph shows the first test case and how the player can reach the configuration without cheating. Each crown marks a special cell.
| Name |
|---|


