#include <stdio.h>
#include <memory.h>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
const int mod = 1000000007;
const int N = 200005;

void solve() {
    int i = 0, n = 0, m = 0, j = 0, k = 0;
    char str[64][64] = { 0 }, to[64] = { 0 };
    scanf("%d%d", &n, &m);
    for (i = 0; i < n; i ++) {
        scanf("%s", str[i]);
    }
    for (i = 0; i < n; i ++) {
        for (j = 0; j < m; j ++) {
            if (str[i][j] == '.') continue;
            k = (i + j) % 2;
            if (to[k] && to[k] != str[i][j]) {
                printf("NO\n");
                return;
            }
            to[k] = str[i][j];
        }
    }
    if (!to[0] && !to[1]) {
        to[0] = 'R';
        to[1] = 'W';
    }
    else if (to[0] == to[1]) {
        printf("NO\n");
        return;
    }
    else if (to[0]) {
        if (to[0] == 'R') {
            to[1] = 'W';
        }
        else {
            to[1] = 'R';
        }
    }
    else {
        if (to[1] == 'R') {
            to[0] = 'W';
        }
        else {
            to[0] = 'R';
        }
    }
    for (i = 0; i < n; i ++) {
        for (j = 0; j < m; j ++) {
            str[i][j] = to[(i+j)%2];
        }
    }
    printf("YES\n");
    for (i = 0; i < n; i ++) {
        printf("%s\n", str[i]);
    }
    
}

int main() {
    int o = 1;
    scanf("%d", &o);
    while (o --) {
        solve();
        //fflush(stdout);
    }
    return 0;
}
