#include<bits/stdc++.h>
using namespace std;
#define ll long long
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;

// typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update>PBDS;
#define mod 1000000007
#define INF 10000000000007
#define DEBUG false
#define N 200005
ll gcd(ll a , ll b) {return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b)
{
	return (a / gcd(a, b)) * b;
}

void solve()
{
	ll n, m;
	cin >> n >> m;
	vector<string> s(n);
	for (ll i = 0; i < n; i++) {
		cin >> s[i];
	}
	vector<string>v1;
	vector<string>v2;
	string a = "";
	ll k = 0;
	while (a.length() < m)
	{
		if (k == 0)a.push_back('R');
		else a.push_back('W');
		k = 1 - k;
	}
	string b = "";
	ll x = 0;
	while (b.length() < m)
	{
		if (x == 0)b.push_back('W');
		else b.push_back('R');
		x = 1 - x;
	}
	//cout << a << endl << b << endl;
	for (ll i = 0; i < n; i++)
	{
		if (i % 2 == 0)v1.push_back(a);
		else v1.push_back(b);
	}
	for (ll i = 0; i < n; i++)
	{
		if (i % 2 == 0)v2.push_back(b);
		else v2.push_back(a);
	}
	ll cnt = 0;
	bool c1 = 1, c2 = 1;
	for (ll i = 0; i < n; i++)
	{
		for (ll j = 0; j < m; j++)
		{
			if (s[i][j] == 'R' and v1[i][j] == 'W')
			{
				c1 = 0;
				break;
			}
			else if (s[i][j] == 'W' and v1[i][j] == 'R')
			{
				c1 = 0;
				break;
			}
			else cnt++;
		}
	}
	if (cnt == n * m) {
		cout << "YES\n";
		for (ll i = 0; i < n; i++)
		{
			cout << v1[i] << "\n";
		}
		return;
	}
	ll cnt2 = 0;
	for (ll i = 0; i < n; i++)
	{
		for (ll j = 0; j < m; j++)
		{
			if (s[i][j] == 'R' and v2[i][j] == 'W')
			{
				c2 = 0;
				break;
			}
			else if (s[i][j] == 'W' and v2[i][j] == 'R')
			{
				c2 = 0;
				break;
			}
			else cnt2++;
		}
	}
	if (cnt2 == n * m) {
		cout << "YES\n";
		for (ll i = 0; i < n; i++)
		{
			cout << v2[i] << "\n";
		}
		return;
	}
	if (c1 == 0 and c2 == 0)
	{
		cout << "NO\n";
		return;
	}
	cout << "YES\n";
	for (ll i = 0; i < n; i++)
	{
		cout << v1[i] << "\n";
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	ll t = 1;
	cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}
