#include<bits/stdc++.h>
using namespace std;
#include<string.h>
#define  int                 long long
#define  pb                  push_back
#define  ppb                 pop_back
#define  pf                  push_front
#define  ppf                 pop_front
#define  fo(i,a,b)           for(int i=a; i<b ; i++)
#define  rfo(i,a,b)          for(int i=a; i>b ; i--)
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL);

int power(int b,int e){if(e==0) return 1; if(e&1) return b*power(b*b,e/2); return power(b*b,e/2);}
int gcd(int a,int b){ if (b==0) {return a;} return gcd(b,a%b); }
bool isPrime(int n){if (n<=1) return false; if (n<=3) return true; if (n%2==0||n%3==0) return false;
        for(int i=5;i*i<=n;i=i+6) if(n%i==0||n%(i+2)==0){ return false;} return true;}
int lcm(int a, int b){return (a*b)/gcd(a,b);}




/*vector<int> ar[2501];
int vis[2501]={0};
int color[2501];
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
    bool dfs(int node,int clr,int len){
    vis[node]=1;
    if(color[node]==-1){color[node]=clr;}
    else{if(color[node]!=clr){return false;}}

    for(int child : ar[node]){
           if(vis[child]==0){
             if(!dfs(child,1-clr,len)){return false;}
           }
           else{
            if(color[child]!=1-clr){return false;}
           }
    }
    return true;
    }
*/



    void Loop_until_T_dies()
    {
    int n; cin>>n;
    int m; cin>>m;
    vector<string>A;
    fo(i,0,n){
    string s; cin>>s;
    A.pb(s);
    }

    int f=0;
    int base=0;
    for(int i=0; i<n ; i++){
        for(int j=0; j<m ; j++){
            if(A[i][j]!='.'){f=1; if(A[i][j]=='R'){if(i%2==j%2){base=1;}else{base=0;}}
                                 else{if(i%2==j%2){base=0;}else{base=1;}}}
           if(f){break;}
        }
        if(f){break;}
    }

         fo(i,0,n){
           fo(j,0,m){
             if(A[i][j]=='.'){
             if(i%2==j%2){if(base==0){A[i][j]='W';} else{A[i][j]='R';}}
             else{if(base==0){A[i][j]='R';} else{A[i][j]='W';}}
             }
             else{
                  char c;
                   if(i%2==j%2){if(base==0){c='W';} else{c='R';}}
                   else{if(base==0){c='R';} else{c='W';}}
                   if(A[i][j]!=c){cout<<"NO"<<endl; return;}
             }
         }
         }

         cout<<"YES"<<endl;
         fo(i,0,n){cout<<A[i]<<endl;}

    return;
    }




//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////

    signed main()
    {
     boost;
    int T=1;
    cin>>T;
        while(T--){
        Loop_until_T_dies();
    }





    return 0;
    }
