#include<bits/stdc++.h>
using namespace std;
	
#define ll long long int
#define endl "\n"
void solve() {	
	int n, m; cin >> n >> m;
	char s1[n][m], s2[n][m], a[n][m];
	
	for(int i=0; i<n;  i++) {
		scanf("%s", a[i]);
	}



	char k1 = 'R', k2 = 'W', k3 = 'W', k4 = 'R';	
	for(int i=0; i<n; i++) {
		for(int j=0; j<m; j++) {
		if(i%2) {
			if(j%2) s1[i][j] = k1, s2[i][j] = k3;
			else s1[i][j] = k2, s2[i][j] = k4;
		}else {
			if(j%2) s1[i][j] = k2, s2[i][j] = k4;
			else s1[i][j] = k1, s2[i][j] = k3;
		}
	}
	}
	int f1 = 0, f2 = 0;	
	for(int i=0; i<n; i++) {
		for(int j=0; j<m; j++) {
			if(a[i][j] != '.' && a[i][j] != s1[i][j]) {
				f1 = 1; 
				break;
			}
		}
	}

	for(int i=0; i<n; i++) {
		for(int j=0; j<m; j++) {
			if(a[i][j] != '.' && a[i][j]!= s2[i][j]) {
				f2 = 1; 
				break;
			}
		}
	}

	if(f1&&f2) {
		cout << "NO" << endl;
		return;
	}


	cout << "YES" << endl;
	if(f1 == 0) {
		for(int i=0; i<n; i++) {
		for(int j=0; j<m; j++) {
			cout << s1[i][j];
		}
		cout << endl;
	}
	}else {
		for(int i=0; i<n; i++) {
		for(int j=0; j<m; j++) {
			cout << s2[i][j];
		}
		cout << endl;
	}
	}

return;
}

int main() {
    //std::ios::sync_with_stdio(false);

    int t; cin >> t;
	
    while(t--) {
		solve();
    }

return 0;
}

