#include <bits/stdc++.h>
#define fore(i,a,b) for(int i = a; i < b; i++)
#define fst first
#define snd second
#define ll long long
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define cin2(x,y) cin>>x>>y;
#define cin3(x,y,z) cin>>x>>y>>z;
#define cin4(x,y,z,w) cin>>x>>y>>z>>w;
#define cout2(x,y) cout<<x<<" "<<y<<endl;
#define cout3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl;
#define cout4(x,y,z,w) cout<<x<<" "<<y<<" "<<z<<" "<<w<<endl;
#define pii pair<int,int>
#define piii pair<int, pii>
#define pll pair<ll,ll>
#define vi vector<int>
#define vii vector<pii>
#define viii vector<piii>
#define vll vector<ll>
#define pb push_back
#define mp make_pair
#define Vector Point
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define openio freopen("in","r",stdin);freopen("out","w",stdout)
#define closeio fclose(stdin);fclose(stdout)

using namespace std;

const int MX = 105;
int A[MX][MX];

int main(){
    int t;
    cin>>t;
    while(t--){
        int n,m;
        cin>>n>>m;
        int pi = 0;
        fore(i,0,n){
            string S;
            cin>>S;
            fore(j,0,m){
                if(S[j]=='R') A[i][j] = 1;
                else if(S[j]=='W') A[i][j] = 2;
                else A[i][j] = 0;
                if(pi==0 and S[j]!='.'){
                    pi = (i+j+A[i][j]);
                }
            }
        }
        bool ans = true;
        fore(i,0,n){
            fore(j,0,m){
                if(A[i][j] and (A[i][j]+i+j)%2 != pi%2){
                    ans = false;
                    break;
                }
                if(pi%2){
                    if((i+j)%2) A[i][j]=2;
                    else A[i][j]=1;
                }
                else{
                    if((i+j)%2) A[i][j]=1;
                    else A[i][j]=2;
                }
            }
        }
        if(ans){
            cout<<"YES\n";
            fore(i,0,n){
                fore(j,0,m){
                    if(A[i][j]==1) cout<<'R';
                    else cout<<'W';
                }
                cout<<endl;
            }
        }
        else cout<<"NO\n";
    }
    return 0;
}