#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<ctime>
#include<cmath>
#include<utility>
#include<cstdlib>
#include<bitset>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<iomanip>
#include<numeric>
#include<fstream>
using namespace std;                       

#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define sc second
#define all(v) v.begin(),v.end()

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const ll M = 1e9 + 7;

void print(vector<ll> &a){
    int n = a.size();
    for(int i=0; i<n; i++){
        cout<<a[i]<<" ";
    }
    cout<<endl;
}

void print(vector<int> &a){
    int n = a.size();
    for(int i=0; i<n; i++){
        cout<<a[i]<<" ";
    }
    cout<<endl;
}


int main(){
    // clock_t time_req;
    // time_req = clock();
    fastio;
    int te;
    cin>>te;
    // te = 1;
    while(te--){
        int n, m;
        cin>>n>>m;
        vector<string> s(n);
        for(int i=0; i<n; i++){
            cin>>s[i];
        }
        bool re = true;
        bool st = false;
        bool ans = true;
        for(int i=0; i<n; i++){
            for(int j=0; j<m; j++){
                bool ie, je;
                if(i%2 == 0) ie = true;
                else ie = false;
                if(j%2 == 0) je = true;
                else je = false;
                if(!st && s[i][j] != '.'){
                    if(s[i][j] == 'R'){
                        re = ie ^ je;
                    }
                    else{
                        re = ! (ie ^ je);
                    }
                    st = true;
                }
                else if(st && s[i][j] != '.'){
                    bool d = ie ^ je;
                    if(s[i][j] == 'R'){
                        if(d != re){
                            ans = false;
                            break;
                        }
                    }
                    else{
                        if(d == re){
                            ans = false;
                            break;
                        }
                    }
                }
            }
            if(!ans) break;
        }
        if(ans) cout<<"YES"<<endl;
        if(ans){
            for(int i=0; i<n; i++){
                for(int j=0; j<m; j++){
                    bool ie, je;
                    if(i%2 == 0) ie = true;
                    else ie = false;
                    if(j%2 == 0) je = true;
                    else je = false;
                    bool d = ie ^ je;
                    if(d == re) s[i][j] = 'R';
                    else s[i][j] = 'W';
                }
                cout<<s[i]<<endl;
            }
        }
        else cout<<"NO"<<endl;
    }
    // time_req = clock()-time_req;
    // cout<<"Time taken: "<<(float)time_req/CLOCKS_PER_SEC<<"s"<<endl;
    return 0;
}