logo AlgoBeat OnlineJudge
登录 注册

#209444. [EC Final 2021] Check Pattern is Bad

内存限制:1024 MiB 时间限制:10000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

Prof. Pang is given an board. Some cells are colored black, some cells are colored white, and others are uncolored.

Prof. Pang doesn't like , so he wants to color all uncolored cells such that there is no check pattern on the board.

cells forming a square are said to have the check pattern if they are colored in one of the following ways:

BW
WB
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 denoting the number of test cases.

The first line of each test case contains two integers and () denoting the dimensions of the board.

Each of the next lines contains characters. The -th character of the -th line represents the status of the cell on the -th row and -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 over all test cases is no more than .

输出格式

For each test case, output a line containing if you cannot color all the uncolored cells such that there is no check pattern on the board.

Otherwise, output a line containing . In the next 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 and .
  • 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