/*
******
**
**
*****
****
****
****
*******
**
**
**
**
**
**
**
**
**
*******
****
****
****
***
**
**
*****

*/
//THEKINGSNOW_BLACK
//YUNUSSALMANDOSEN'TGIVEUP
//J'AIMESYRIA
#include<iostream>
#include<string>
using namespace std;
#define ll long long
inline bool is(ll ans,ll d)
{
ll sum=ans*(ans+1)/2;
if(sum<d)return 0;
return(sum%2==d%2);
}
/*
*O***

G***O

**O**

G***

***G
*/
int main()
{
ll t;cin>>t;
for(ll oppo=0;oppo<t;++oppo)
{
ll n,m; cin>>n>>m;
char a[1000][1000],ans1[1000][1000],ans2[1000][1000];
for(ll i=0;i<n;++i)
{
for(ll j=0;j<m;++j)
{
cin>>ans2[i][j];
}
}
for(ll i=1;i<n;i+=2){
for(ll j=0;j<m;j+=2){
a[i][j]='W';
ans1[i][j]='R';
}
}
for(ll i=0;i<n;i+=2){
for(ll j=1;j<m;j+=2){
a[i][j]='W';
ans1[i][j]='R';
}
}
for(ll i=1;i<n;i+=2){
for(ll j=1;j<m;j+=2){
a[i][j]='R';
ans1[i][j]='W';
}
}
for(ll i=0;i<n;i+=2){
for(ll j=0;j<m;j+=2){
a[i][j]='R';
ans1[i][j]='W';
}
}
bool mm=0,o=0,w=0;
for(ll i=0;i<n;++i){
for(ll j=0;j<m;++j){
if(a[i][j]!=ans2[i][j]&&ans2[i][j]!='.'){
mm=1;
}
if(ans1[i][j]!=ans2[i][j]&&ans2[i][j]!='.'){
o=1;
}
}
}
if(mm==1&&o==1){
cout<<"NO"<<endl;
}
else{
cout<<"YES"<<endl;
if(mm==0){
for(ll i=0;i<n;++i){
for(ll j=0;j<m;++j){
cout<<a[i][j];
}
cout<<endl;
}
}
else if(o==0){
for(ll i=0;i<n;++i){
for(ll j=0;j<m;++j){
cout<<ans1[i][j];
}
cout<<endl;
}
}
}
}
}
