
// Problem : A. Colour the Flag
// Contest : Codeforces - Codeforces LATOKEN Round 1 (Div. 1 + Div. 2)
// URL : https://codeforces.com/contest/1534/problem/A
// Memory Limit : 256 MB
// Time Limit : 1500 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back
#define vi vector<int>
#define pii pair<int, int>
#define pll pair<long long, long long>
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}

const int p = 1e9 + 7;
const int lim = 2004;

void pre_io(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
}

int32_t main()
{
	pre_io();
	int test;
	cin>>test;
	while(test--){
		int n, m;
		cin>>n>>m;
		vector<string> v(n);
		for(int i=0; i<n; i++) cin>>v[i];
		
		int assn = -1;
		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				if(v[i][j]=='R'){
					assn = (i+j)%2;
				}else if(v[i][j]=='W'){
					assn = 1 - (i+j)%2;
				}
			}
		}
		
		if(assn==-1){
			cout<<"YES\n";
			for(int i=0; i<n; i++){
				for(int j=0; j<m; j++){
					v[i][j] = ((i+j)%2 == 0?'R':'W');
				}
			}
			
			for(auto s: v) cout<<s<<"\n";
			continue;
		}
		
		bool doable = true;
		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				char ch = ((i+j)%2 == assn ? 'R':'W');
				
				if(v[i][j] == '.'){
					v[i][j] = ch;
				}else if(v[i][j] == ch){
					continue;
				}else{
					doable = false;
					break;
				}
			}
			
			if(!doable) break;
		}
		
		if(!doable){
			cout<<"NO\n";
			continue;
		}
		
		cout<<"YES\n";
		for(auto u: v) cout<<u<<"\n";
	}
}