#include <bits/stdc++.h>

using namespace std;

#define fast ios_base::sync_with_stdio(false);\
             cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define mod 1000000007
const int N = 1e7 + 2;

//vector<bool> prime(N, true);

//void sieve(){
//    prime[0] = prime[1] = false;
//    for (int i=2; i*i < N; i++){
//        if (prime[i]){
//            for (int j=i*i; j<N; j+=i)
//                prime[j] = false;
//        }
//    }
//}

void solve(){
    int n,m;
    cin>>n>>m;
    char a[n][m];
    char b[n][m];
    char c[n][m];
    bool flip=0;
    for (int i=0;i<n;i++){
        if (!(m & 1)){
            flip = !flip;
        }
        for (int j=0;j<m;j++){
            if (flip){
                b[i][j] = 'R';
            }
            else{
                b[i][j] = 'W';
            }
            flip = !flip;
        }
    }
    flip = 1;
    for (int i=0;i<n;i++){
        if (!(m & 1)){
            flip = !flip;
        }
        for (int j=0;j<m;j++){
            if (flip){
                c[i][j] = 'R';
            }
            else{
                c[i][j] = 'W';
            }
            flip = !flip;
        }
    }
    bool ansb=1,ansc=1;
    for (int i=0;i<n;i++){
        for (int j=0;j<m;j++){
            cin>>a[i][j];
            if (a[i][j] == '.'){
                continue;
            }
            if (a[i][j] != b[i][j]){
                ansb=0;
            }
            if (a[i][j] != c[i][j]){
                ansc=0;
            }
        }
    }
    if (ansb){
        cout<<"YES\n";
        for (int i=0;i<n;i++){
            for (int j=0;j<m;j++)
                cout<<b[i][j];
            cout<<"\n";
        }
    }
    else if (ansc){
        cout<<"YES\n";
        for (int i=0;i<n;i++){
            for (int j=0;j<m;j++)
                cout<<c[i][j];
            cout<<"\n";
        }
    }
    else{
        cout<<"NO\n";
    }
}

int main() {
    fast;
    int t; cin>>t;
    while(t--) solve();
    return 0;
}