#P1749E. Cactus Wall

    ID: 8019 Type: RemoteJudge 2000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>constructive algorithmsdfs and similargraphsshortest paths

Cactus Wall

No submission language available for this problem.

Description

Monocarp is playing Minecraft and wants to build a wall of cacti. He wants to build it on a field of sand of the size of n×mn \times m cells. Initially, there are cacti in some cells of the field. Note that, in Minecraft, cacti cannot grow on cells adjacent to each other by side — and the initial field meets this restriction. Monocarp can plant new cacti (they must also fulfil the aforementioned condition). He can't chop down any of the cacti that are already growing on the field — he doesn't have an axe, and the cacti are too prickly for his hands.

Monocarp believes that the wall is complete if there is no path from the top row of the field to the bottom row, such that:

  • each two consecutive cells in the path are adjacent by side;
  • no cell belonging to the path contains a cactus.

Your task is to plant the minimum number of cacti to build a wall (or to report that this is impossible).

The first line contains a single integer tt (1t1031 \le t \le 10^3) — number of test cases.

The first line of each test case contains two integers nn and mm (2n,m21052 \le n, m \le 2 \cdot 10^5; n×m4105n \times m \le 4 \cdot 10^5) — the number of rows and columns, respectively.

Then nn rows follow, ii-th row contains a string sis_i of length mm, where si,js_{i, j} is '#', if a cactus grows at the intersection of the ii-th row and the jj-th column. Otherwise, si,js_{i, j} is '.'.

The sum of n×mn \times m over all test cases does not exceed 41054 \cdot 10^5.

For each test case, print NO in the first line if it is impossible to build a cactus wall without breaking the rules. Otherwise, print YES in the first line, then print nn lines of mm characters each — the field itself, where the jj-th character of the ii-th line is equal to '#', if there is a cactus on the intersection of the ii-th row and the jj-th column, otherwise it is '.'. If there are multiple optimal answers, print any of them.

Input

The first line contains a single integer tt (1t1031 \le t \le 10^3) — number of test cases.

The first line of each test case contains two integers nn and mm (2n,m21052 \le n, m \le 2 \cdot 10^5; n×m4105n \times m \le 4 \cdot 10^5) — the number of rows and columns, respectively.

Then nn rows follow, ii-th row contains a string sis_i of length mm, where si,js_{i, j} is '#', if a cactus grows at the intersection of the ii-th row and the jj-th column. Otherwise, si,js_{i, j} is '.'.

The sum of n×mn \times m over all test cases does not exceed 41054 \cdot 10^5.

Output

For each test case, print NO in the first line if it is impossible to build a cactus wall without breaking the rules. Otherwise, print YES in the first line, then print nn lines of mm characters each — the field itself, where the jj-th character of the ii-th line is equal to '#', if there is a cactus on the intersection of the ii-th row and the jj-th column, otherwise it is '.'. If there are multiple optimal answers, print any of them.

Sample Input 1

4
2 4
.#..
..#.
3 3
#.#
...
.#.
5 5
.....
.....
.....
.....
.....
4 3
#..
.#.
#.#
...

Sample Output 1

YES
.#.#
#.#.
NO
YES
....#
...#.
..#..
.#...
#....
YES
#..
.#.
#.#
...