#include<bits/stdc++.h>
using namespace std;
#define ll					long long int
#define mihir				ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb					push_back
#define pairll				pair<ll,ll>

const int N = (int)(1 * 1e5 + 9);



void fff() {

	mihir
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}



int main()
{
	fff();

	int t;
	cin >> t;
	while (t--) {
		int n, m;
		cin >> n >> m;
		char arr[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m ; j++)
				cin >> arr[i][j];
		}

		char brr[n][m];
		char crr[n][m];

		for (int i = 0; i < n ; i++) {
			for (int j = 0; j < m; j++) {
				if (i % 2 == 0) {
					if ( j % 2 != 0)
						brr[i][j] = 'R';
					else
						brr[i][j] = 'W';
				} else {
					if ( j % 2 != 0)
						brr[i][j] = 'W';
					else
						brr[i][j] = 'R';
				}
			}
		}

		for (int i = 0; i < n ; i++) {
			for (int j = 0; j < m; j++) {
				if (i % 2 == 0) {
					if ( j % 2 != 0)
						crr[i][j] = 'W';
					else
						crr[i][j] = 'R';
				} else {
					if ( j % 2 != 0)
						crr[i][j] = 'R';
					else
						crr[i][j] = 'W';
				}
			}
		}

		bool flag = true, flag2 = true;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (arr[i][j] != '.')
					if (arr[i][j] != brr[i][j]) {
						flag = false;
						break;
					}
			}
		}

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (arr[i][j] != '.') {
					if (arr[i][j] != crr[i][j]) {
						flag2 = false;
						break;
					}
				}
			}
		}

		if (flag || flag2) {
			cout << "YES" << endl;
			if (flag) {
				for (int i = 0; i < n; i++) {
					for (int j = 0; j < m; j++)
						cout << brr[i][j] ;
					cout << endl;
				}
			}
			else {
				for (int i = 0; i < n; i++) {
					for (int j = 0; j < m; j++)
						cout << crr[i][j] ;
					cout << endl;
				}
			}
		}
		else
			cout << "NO" << endl;
	}


	return 0;
}