#include <bits/stdc++.h>
using namespace std;            //ITS NOT OVER UNTIL I WIN
typedef long long ll;
const int  mod = 1e9+7;
class sop{
  public:
  int x=0,y=0;
  
};
void print(char even,char odd,int n,int m){
for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
        if((i+j)%2==0){
        cout<<even;
        }
        else cout<<odd;
        }
        cout<<"\n";
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cout.tie(NULL);
    cin.tie(NULL);
    int T=1;
    cin>>T;
    while(T--){
        int n,m;
        cin>>n>>m;
        sop odd,even;
        for(int i=0;i<n;i++){
            string a;
            cin>>a;
            for(int j=0;j<m;j++){
                if((i+j)%2==0){
                    if(a[j]=='R')even.x=1;
                    if(a[j]=='W')even.y=1;
                }
                else{
                    if(a[j]=='R')odd.x=1;
                    if(a[j]=='W')odd.y=1;
                }
            }
        }
        if((even.x==1&&odd.x==1)||(even.y==1&&odd.y==1)||(even.x==1&&even.y==1)||(odd.x==1&&odd.y==1))cout<<"NO\n";
        else {cout<<"YES\n";
            if(even.x==1||odd.y==1){
                print('R','W',n,m);
            }
            else{
                print('W','R',n,m);
            }
            
        }
        
    }
    return 0;
}