#include <bits/stdc++.h>
using namespace std;
#define int  long long int
#define mod 1000000007
#define pb push_back
// #define mp make_pair
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define gcd __gcd
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(i) i.begin(),i.end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define set_bit __builtin_popcount //gives number of set_bits
#define ff first
#define ss second
#define cases(t) int t;cin>>t; rep(casn,1,t+1)
#define el cout<<endl;
#define deci(n) int n; scanf("%lld",&n);
#define decs(n) string n; cin>>n;
#define sz(v) v.size()
#define repit(m) for(auto it=m.begin();it!=m.end();it++)
#define debx cout<<"->";
#define deb(x) cout<<#x<<" "<<x<<endl;
#define cYES cout<<"YES\n";
#define cNO cout<<"NO\n";
#define ins insert
#define imax 10000000000000000
#define imin -1000000000000000
#define pii pair<int,pair<int,int>>
//  cerr << "\nTime : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
//  IIITA
// scanning numbers extremely fast/////////

void fs(int &number)
{
    bool negative = false;
    register int c;
    number = 0;
    c = getchar();
    if (c=='-')
    {
        negative = true;
        c = getchar();
    }
    for (; (c>47 && c<58); c=getchar())
        number = number *10 + c - 48;
    if (negative)
        number *= -1;
}

// ========================================
int power(int a,int x)
{
    a%=mod;
    int res=1;
    while(x>0)
    {
        if(x&1)
        res=res*a%mod;
        a=a*a%mod;
        x>>=1;
    }
    return res;

}

int max(int a,int b)
{
    if(a>b)
    {
        return a;
    }
    else
    {
        return b;
    }
}

int min(int a,int b)
{
    if(a>b)
    {
        return b;
    }
    else
    {
        return a;
    }
}
int madd(int a,int b)
{
    int ans;
    ans=(a%mod+b%mod)%mod;
    return ans;
}
int mmult(int a,int b)
{
    int ans=1;
    ans=((a%mod)*(b%mod))%mod;
    return ans%mod;
}
int modinverse(int a)
{
    return power(a,mod-2);
}
// int fact[500004];
// void Factorial()
// {
//     fact[0]=1;
//     for(int i=1;i<=200001;i++)
//     {
//         fact[i]=mmult(fact[i-1],i);
//     }
// }
// int ncr(int n,int r)
// {
//     if(r>n)
//     {
//         return 0;
//     }
//     if(n==r||r==0)
//     {
//         return 1;
//     }
//     if(n==0)
//     {
//         return 0;
//     }
//     // return fact[n]/(fact[r]*fact[n-r]);
//     return  mmult(fact[n],modinverse(mmult(fact[r],fact[n-r])));
// }
 

void solve()
{   
	int n,m;cin>>n>>m;
	string s;
	int dp[n+1][m+1];
// 	1->r
// 2->w
// -1 -> .
	int count =0;
	for(int i=0;i<n;i++)
	{
		cin>>s;
		
		for(int j=0;j<m;j++)
		{
			if(s[j]=='R')
			{
				dp[i][j]=1;
				count++;
			}
			else if(s[j]=='W')
			{
				dp[i][j]=2;
				count++;
			}
			else
			{
				dp[i][j] = -1;
			}
		}
	}
		 
	// cout<<count<<endl;
	if(count==0)
	{
		dp[0][0]=1;
		count++;
	}
	while(1)
	{
		// int flag=0;
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				if(dp[i][j]==1)
				{
					if(i+1<n)
					{
						if(dp[i+1][j]==1)
						{
							cout<<"NO\n";
							return ;
						}
						dp[i+1][j]=2;
					}
					if(i-1>=0)
					{
						if(dp[i-1][j]==1)
						{
							cout<<"NO\n";
							return ;
						}
						dp[i-1][j]=2;
					}
					if(j-1>=0)
					{
						if(dp[i][j-1]==1)
						{
							cout<<"NO\n";
							return;
						}
						dp[i][j-1]=2;
					}
					if(j+1<m)
					{
						if(dp[i][j+1]==1)
						{
							cout<<"NO\n";
							return ;
						}
						dp[i][j+1]=2;
					}
				}
				if(dp[i][j]==2)
				{
					if(i+1<n)
					{
						if(dp[i+1][j]==2)
						{
							cout<<"NO\n";
							return ;
						}
						dp[i+1][j]=1;
					}
					if(i-1>=0)
					{
						if(dp[i-1][j]==2)
						{
							cout<<"NO\n";
							return ;
						}
						dp[i-1][j]=1;
					}
					if(j-1>=0)
					{
						if(dp[i][j-1]==2)
						{
							cout<<"NO\n";
							return;
						}
						dp[i][j-1]=1;
					}
					if(j+1<m)
					{
						if(dp[i][j+1]==2)
						{
							cout<<"NO\n";
							return ;
						}
						dp[i][j+1]=1;
					}
				}
			}
		}
		
		int csum=0;
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				if(dp[i][j] == -1)
				{
					// cout<<"->"<<i<<" "<<j<<endl;
					csum++;
				}
			}
		}
		// cout<<csum<<endl;
		
		if(csum==0)
		{
			break;
		}
	}
	
	cout<<"YES\n";
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(dp[i][j]==1)
			{
				cout<<"R";
			}
			else
			{
				cout<<"W";
			}
		}
		el
	}
	// el
}
signed main()
{
	fastio; 
    
    int test;
    // test=1;
    cin>>test;
    for(int i=1;i<=test;i++)
    {
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}