[EC Final 2021] Check Pattern is Bad

题意翻译

$n \times m$ 的棋盘,知道一些位置是黑色的,一些位置是白色的,一些位置不知道是什么颜色。 请你构造一种方案让棋盘的每个位置被染成黑色或白色(已知的位置不能换颜色),使得棋盘上不存在子矩阵: ``` BW WB ``` 以及 ``` WB BW ``` 多组询问。

题目描述

Prof. Pang is given an $n\times m$ board. Some cells are colored black, some cells are colored white, and others are uncolored. Prof. Pang doesn't like $\textbf{check patterns}$, so he wants to color all uncolored cells such that there is no check pattern on the board. $4$ cells forming a $2\times 2$ square are said to have the check pattern if they are colored in one of the following ways: ```plain BW WB ``` ```plain WB BW ``` Here `W` ("wakuda" in Chewa language) means the cell is colored black and `B` ("biancu" in Corsican language) means the cell is colored white.

输入输出格式

输入格式


The first line contains a single integer $T$ $(1\leq T \leq 10^4)$ denoting the number of test cases. The first line of each test case contains two integers $n$ and $m$ ($1\le n, m\le 100$) denoting the dimensions of the board. Each of the next $n$ lines contains $m$ characters. The $j$-th character of the $i$-th line represents the status of the cell on the $i$-th row and $j$-th column of the board. The character is `W` if the cell is colored black, `B` if the cell is colored white, and `?` if the cell is uncolored. It is guaranteed that the sum of $nm$ over all test cases is no more than $10^6$.

输出格式


For each test case, output a line containing $\texttt{NO}$ if you cannot color all the uncolored cells such that there is no check pattern on the board. Otherwise, output a line containing $\texttt{YES}$. In the next $n$ lines, output the colored board in the same format as the input. The output board should satisfy the following conditions. - It does not have any check pattern. - It consists of only $\texttt{B}$ and $\texttt{W}$. - If a cell is already colored in the input, its color cannot be changed in the output. If there are multiple solutions, output any of them.

输入输出样例

输入样例 #1

3
2 2
??
??
3 3
BW?
W?B
?BW
3 3
BW?
W?W
?W?

输出样例 #1

YES
BW
WW
NO
YES
BWB
WWW
BWB