Today we will be playing a red and white colouring game (no, this is not the Russian Civil War; these are just the colours of the Canadian flag).

You are given an $n \times m$ grid of "R", "W", and "." characters. "R" is red, "W" is white and "." is blank. The neighbours of a cell are those that share an edge with it (those that only share a corner do not count).

Your job is to colour the blank cells red or white so that every red cell only has white neighbours (and no red ones) and every white cell only has red neighbours (and no white ones). You are not allowed to recolour already coloured cells.


-----Input-----

The first line contains $t$ ($1 \le t \le 100$), the number of test cases.

In each test case, the first line will contain $n$ ($1 \le n \le 50$) and $m$ ($1 \le m \le 50$), the height and width of the grid respectively.

The next $n$ lines will contain the grid. Each character of the grid is either 'R', 'W', or '.'.


-----Output-----

For each test case, output "YES" if there is a valid grid or "NO" if there is not.

If there is, output the grid on the next $n$ lines. If there are multiple answers, print any.

In the output, the "YES"s and "NO"s are case-insensitive, meaning that outputs such as "yEs" and "nO" are valid. However, the grid is case-sensitive.


-----Examples-----

Input
3
4 6
.R....
......
......
.W....
4 4
.R.W
....
....
....
5 1
R
W
R
W
R
Output
YES
WRWRWR
RWRWRW
WRWRWR
RWRWRW
NO
YES
R
W
R
W
R


-----Note-----

The answer for the first example case is given in the example output, and it can be proven that no grid exists that satisfies the requirements of the second example case. In the third example all cells are initially coloured, and the colouring is valid.

Difficulty: EASY
Tags: Implementation

Complete search
Skill types: Complete search

Starter code:

Solutions:
def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def msi():
	return map(str, input().split())

def li():
	return list(mi())
t = ii()
for _ in range(t):
	(n, m) = mi()
	mat = []
	for z in range(n):
		mat.append(list(si()))
	(r, w) = ([], [])
	for i in range(n):
		for j in range(m):
			if mat[i][j] == 'R':
				r.append(i + j)
			if mat[i][j] == 'W':
				w.append(i + j)
	flag = 0
	if len(list(filter(lambda x: x % 2 == 0, r))) == 0 and len(list(filter(lambda x: x % 2 == 1, w))) == 0:
		flag = 1
	if len(list(filter(lambda x: x % 2 == 1, r))) == 0 and len(list(filter(lambda x: x % 2 == 0, w))) == 0:
		flag = 2
	if flag > 0:
		for i in range(n):
			for j in range(m):
				if mat[i][j] == '.':
					if (i + j) % 2 == 0:
						if flag == 1:
							mat[i][j] = 'W'
						else:
							mat[i][j] = 'R'
					elif flag == 1:
						mat[i][j] = 'R'
					else:
						mat[i][j] = 'W'
		print('YES')
		for row in mat:
			print(''.join(row))
	else:
		print('NO')


import sys
input = sys.stdin.readline

def solve():
	(n, m) = map(int, input().split())
	orientation = ['R', 'W']
	fixed = False
	flag = True
	for i in range(n):
		row = input()
		for j in range(m):
			if row[j] == '.':
				continue
			if not fixed:
				if orientation[(i + j) % 2] != row[j]:
					orientation.reverse()
				fixed = True
			elif orientation[(i + j) % 2] != row[j]:
				flag = False
	if not flag:
		print('NO')
		return
	print('YES')
	for i in range(n):
		for j in range(m):
			print(end=orientation[(i + j) % 2])
		print()
for _ in range(int(input())):
	solve()


for t in range(int(input())):
	(N, M) = tuple(map(int, input().split()))
	AA = [input() for n in range(N)]
	t = None
	flag = False
	for n in range(N):
		for m in range(M):
			if AA[n][m] == '.':
				continue
			p = ((AA[n][m] == 'W') - n - m) % 2
			if t == None:
				t = p
			elif t != p:
				flag = True
				break
		if flag:
			break
	if flag:
		print('NO')
	else:
		print('YES')
		if t == None:
			t = 0
		for n in range(N):
			R = ''
			for m in range(M):
				if (t + n + m) % 2:
					R += 'W'
				else:
					R += 'R'
			print(R)


import os.path
from math import gcd, floor, ceil
from collections import *
import sys
mod = 1000000007
INF = float('inf')

def st():
	return list(sys.stdin.readline().strip())

def li():
	return list(map(int, sys.stdin.readline().split()))

def mp():
	return map(int, sys.stdin.readline().split())

def inp():
	return int(sys.stdin.readline())

def pr(n):
	return sys.stdout.write(str(n) + '\n')

def prl(n):
	return sys.stdout.write(str(n) + ' ')
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
dx = [0, 0, 1, -1]
dy = [1, -1, 0, 0]

def solve():
	(n, m) = mp()
	l = [st() for i in range(n)]
	a = []
	b = []
	for i in range(m):
		if i % 2 == 0:
			a.append('R')
			b.append('W')
		else:
			b.append('R')
			a.append('W')
	x = []
	y = []
	for i in range(n):
		if i % 2 == 0:
			x.append(a)
			y.append(b)
		else:
			y.append(a)
			x.append(b)
	i = 0
	f = 0
	while i < n and f == 0:
		for j in range(m):
			if l[i][j] != '.' and l[i][j] != y[i][j]:
				f = 1
				break
		i += 1
	if not f:
		pr('YES')
		for i in y:
			print(*i, sep='')
		return
	f = 0
	i = 0
	while i < n and f == 0:
		for j in range(m):
			if l[i][j] != '.' and l[i][j] != x[i][j]:
				f = 1
				break
		i += 1
	if not f:
		pr('YES')
		for i in x:
			print(*i, sep='')
		return
	pr('NO')
for _ in range(inp()):
	solve()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = [' ' for i in range(n)]
	a = [' ' for i in range(n)]
	b = [' ' for i in range(n)]
	for i in range(n):
		l[i] = input()
		if i % 2 == 0:
			a[i] = 'RW' * (m // 2)
			a[i] += 'R' * (m - 2 * (m // 2))
			b[i] = 'WR' * (m // 2)
			b[i] += 'W' * (m - 2 * (m // 2))
		else:
			b[i] = 'RW' * (m // 2)
			b[i] += 'R' * (m - 2 * (m // 2))
			a[i] = 'WR' * (m // 2)
			a[i] += 'W' * (m - 2 * (m // 2))
	c1 = 1
	c2 = 1
	for i in range(n):
		for j in range(m):
			if l[i][j] != '.':
				if l[i][j] != a[i][j]:
					c1 = 0
					break
		if c1 == 0:
			break
	for i in range(n):
		for j in range(m):
			if l[i][j] != '.':
				if l[i][j] != b[i][j]:
					c2 = 0
					break
		if c2 == 0:
			break
	if c1 + c2 > 0:
		print('YES')
	else:
		print('NO')
	if c1 != 0:
		for i in range(n):
			print(a[i])
	elif c2 != 0:
		for i in range(n):
			print(b[i])


def solve():
	(n, m) = map(int, input().split())
	flag1 = True
	flag2 = True
	s1 = [[0] * n for _ in range(n)]
	s = [[0] * m for _ in range(n)]
	for i in range(n):
		s1[i] = list(input())
	for i in range(n):
		for j in range(m):
			if (i + j) % 2 == 0:
				s[i][j] = 'W'
			else:
				s[i][j] = 'R'
			if s1[i][j] != '.' and s[i][j] != s1[i][j]:
				flag1 = False
	for i in range(n):
		for j in range(m):
			if (i + j) % 2 == 0:
				s[i][j] = 'R'
			else:
				s[i][j] = 'W'
			if s1[i][j] != '.' and s[i][j] != s1[i][j]:
				flag2 = False
	if flag2:
		print('YES')
		for i in range(n):
			print(''.join(s[i]))
	elif flag1:
		print('YES')
		for i in range(n):
			for j in range(m):
				if (i + j) % 2 == 0:
					s[i][j] = 'W'
				else:
					s[i][j] = 'R'
		for i in range(n):
			print(''.join(s[i]))
	else:
		print('NO')
for _ in range(int(input())):
	solve()


iter = int(input())
for iters in range(iter):
	(n, m) = input().split(' ')
	(n, m) = (int(n), int(m))
	array = ['.' * m] * n
	for i in range(n):
		array[i] = input()
		valid = True
		found1 = False
		R = 0
		W = 0
	for i in range(n):
		for j in range(m):
			if found1 == False:
				if array[i][j] == '.':
					pass
				elif array[i][j] == 'R':
					R = (i + j) % 2
					W = (R + 1) % 2
					found1 = True
				else:
					R = (i + j + 1) % 2
					W = (R + 1) % 2
					found1 = True
			elif array[i][j] == '.':
				pass
			elif array[i][j] == 'R':
				if (i + j) % 2 != R:
					valid = False
					break
				else:
					continue
			elif (i + j) % 2 != W:
				valid = False
				break
			else:
				continue
		if valid == False:
			break
	if valid == False:
		print('NO')
	else:
		print('YES')
		if R == 1:
			even = 'W'
			odd = 'R'
		else:
			odd = 'W'
			even = 'R'
		first_Row = (even + odd) * (m // 2) + even * (m % 2)
		second_row = (odd + even) * (m // 2) + odd * (m % 2)
		for i in range(n):
			if i % 2 == 0:
				print(first_Row)
			else:
				print(second_row)


from collections import defaultdict
import math
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	b = []
	for i in range(n):
		s = input()
		c = []
		for j in s:
			c.append(j)
		b.append(c)
	f = 1
	r = -1
	w = -1
	for i in range(n):
		for j in range(m):
			if b[i][j] == 'R':
				if r == -1:
					r = (i + j) % 2
				elif r != (i + j) % 2:
					f = 0
					break
			elif b[i][j] == 'W':
				if w == -1:
					w = (i + j) % 2
				elif w != (i + j) % 2:
					f = 0
					break
	if f == 0:
		print('NO')
	else:
		if r == -1 and w == -1:
			r = 0
			w = 1
		elif r == -1:
			if w == 0:
				r = 1
			else:
				r = 0
		elif w == -1:
			if r == 0:
				w = 1
			else:
				w = 0
		if r != w:
			for i in range(n):
				for j in range(m):
					if b[i][j] == '.':
						if r == (i + j) % 2:
							b[i][j] = 'R'
						else:
							b[i][j] = 'W'
			print('YES')
			for i in range(n):
				print(''.join(b[i]))
		else:
			print('NO')


for t in range(int(input())):
	(n, m) = map(int, input().split())
	a = [list(input()) for i in range(n)]
	o = ''
	for i in range(n):
		for j in range(m):
			if a[i][j] == 'R':
				if (i + j) % 2 == 0:
					o = 'R'
				else:
					o = 'W'
				break
			elif a[i][j] == 'W':
				if (i + j) % 2 == 0:
					o = 'W'
				else:
					o = 'R'
				break
		else:
			continue
		break
	if o == '':
		o = 'R'
	reo = 'W' if o == 'R' else 'R'
	for i in range(n):
		for j in range(m):
			if (i + j) % 2 == 0:
				k = o
			else:
				k = reo
			if a[i][j] in 'WR' and k != a[i][j]:
				print('NO')
				break
			else:
				a[i][j] = k
		else:
			continue
		break
	else:
		print('YES')
		for i in range(n):
			print(''.join(a[i]))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	A = []
	for i in range(n):
		s = input()
		l = []
		for j in s:
			l.append(j)
		A.append(l)
	start = 'W'
	end = 'R'
	ans = 'YES'
	B = []
	C = []
	for i in range(n):
		l = [start if j % 2 == 0 else end for j in range(k)]
		l2 = [end if j % 2 == 0 else start for j in range(k)]
		B.append(l)
		C.append(l2)
		c = start
		start = end
		end = c
	check1 = 0
	check2 = 0
	for i in range(n):
		for j in range(k):
			if A[i][j] != '.' and A[i][j] != B[i][j]:
				check1 += 1
				break
		if check1 == 1:
			break
	if check1 == 0:
		print('YES')
		for i in range(n):
			s = ''.join(B[i])
			print(s)
	else:
		for i in range(n):
			for j in range(k):
				if A[i][j] != '.' and A[i][j] != C[i][j]:
					check2 += 1
					break
			if check2 == 1:
				break
		if check2 == 0:
			print('YES')
			for i in range(n):
				s = ''.join(C[i])
				print(s)
		else:
			print('NO')


import re
import sys
exit = sys.exit
from bisect import bisect_left as bsl, bisect_right as bsr
from collections import Counter, defaultdict as ddict, deque
from functools import lru_cache
cache = lru_cache(None)
from heapq import *
from itertools import *
from math import inf
from pprint import pprint as pp
enum = enumerate
ri = lambda : int(rln())
ris = lambda : list(map(int, rfs()))
rln = sys.stdin.readline
rl = lambda : rln().rstrip('\n')
rfs = lambda : rln().split()
cat = ''.join
catn = '\n'.join
mod = 1000000007
d4 = [(0, -1), (1, 0), (0, 1), (-1, 0)]
d8 = [(-1, -1), (0, -1), (1, -1), (-1, 0), (1, 0), (-1, 1), (0, 1), (1, 1)]
(A, B) = ([], [])
rw = 'RW' * 25
wr = 'WR' * 25
for i in range(50):
	if i % 2 == 0:
		(s, t) = (rw, wr)
	else:
		(s, t) = (wr, rw)
	A.append(s)
	B.append(t)

def isgood(m, n, a, b):
	for i in range(m):
		for j in range(n):
			if a[i][j] != '.' and a[i][j] != b[i][j]:
				return 0
	return 1

def solve():
	(m, n) = ris()
	a = [rl() for _ in range(m)]
	for b in (A, B):
		if isgood(m, n, a, b):
			ans = 'YES\n'
			ans += catn((b[i][:n] for i in range(m)))
			return ans
	return 'NO'
t = ri()
for _ in range(t):
	print(solve())


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
t = int(input())
reverse = {'R': 'W', 'W': 'R'}

def matches(ans, grid, n, m):
	for x in range(n):
		for y in range(m):
			if grid[x][y] != '.' and grid[x][y] != ans[x][y]:
				return False
	return True

def makeAns(c):
	ans = [[c for y in range(m)] for x in range(n)]
	for x in range(n):
		if x & 1:
			for y in range(1, m, 2):
				ans[x][y] = reverse[c]
		else:
			for y in range(0, m, 2):
				ans[x][y] = reverse[c]
	return ans
for _ in range(t):
	(n, m) = map(int, input().split())
	grid = []
	for i in range(n):
		grid.append([x for x in input()])
	ans1 = makeAns('R')
	ans2 = makeAns('W')
	if matches(ans1, grid, n, m):
		print('YES')
		for x in ans1:
			print(''.join(x))
	elif matches(ans2, grid, n, m):
		print('YES')
		for x in ans2:
			print(''.join(x))
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = [set(), set()]
	for ni in range(n):
		l = input()
		for mi in range(m):
			if l[mi] in {'R', 'W'}:
				a[(ni + mi) % 2].add(l[mi])
	if len(a[0]) <= 1 and len(a[1]) <= 1 and (len(a[0] & a[1]) == 0):
		print('YES')
		a = ['R', 'W'] if 'R' in a[0] or 'W' in a[1] else ['W', 'R']
		for ni in range(n):
			print(*[a[(ni + mi) % 2] for mi in range(m)], sep='')
	else:
		print('NO')


def solve():
	(n, m) = map(int, input().split())
	v1 = 'WR' * (m // 2) + 'W' * (m % 2)
	v2 = 'RW' * (m // 2) + 'R' * (m % 2)
	m1 = []
	m2 = []
	for i in range(n):
		if i % 2:
			m1.append(v1)
			m2.append(v2)
		else:
			m1.append(v2)
			m2.append(v1)
	matched_v = set()
	for i in range(n):
		s = input()
		for j in range(m):
			if s[j] in ('W', 'R'):
				if s[j] == m1[i][j]:
					matched_v.add(1)
				else:
					matched_v.add(2)
	if len(matched_v) == 2:
		print('NO')
		return
	print('YES')
	try:
		matched_v = tuple(matched_v)[0]
		if matched_v == 1:
			print(*m1, sep='\n')
		else:
			print(*m2, sep='\n')
	except:
		print(*m1)
for _ in range(int(input())):
	solve()


loop = int(input())
while loop > 0:
	loop -= 1
	(a, b) = map(int, input().split())
	str = []
	for i in range(a):
		str.append(input())
	rsum = -1
	wsum = -1
	brk = True
	for i in range(0, a):
		if brk:
			for j in range(0, b):
				if str[i][j] == 'R' and rsum < 0:
					rsum = i + j
					brk = False
					break
				elif str[i][j] == 'W' and wsum < 0:
					wsum = i + j
					brk = False
					break
		else:
			break
	res = []
	if rsum >= 0:
		for i in range(a):
			s = ''
			for j in range(b):
				if (i + j) % 2 == rsum % 2:
					s += 'R'
				else:
					s += 'W'
			res.append(s)
	else:
		for i in range(a):
			s = ''
			for j in range(b):
				if (i + j) % 2 == wsum % 2:
					s += 'W'
				else:
					s += 'R'
			res.append(s)
	inv = False
	for i in range(a):
		for j in range(b):
			if str[i][j] != '.' and str[i][j] != res[i][j]:
				inv = True
	if inv:
		print('NO')
	else:
		print('YES')
		for i in res:
			print(i)


def listToString(s):
	str1 = ''
	return str1.join(s)
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = []
	for i in range(n):
		a = list(input())
		l.append(a)
	ans = [[-1 for i in range(m)] for i in range(n)]
	res = [[-1 for i in range(m)] for i in range(n)]
	k = 0
	for i in range(n):
		for j in range(m):
			if (j + i) % 2 == 0:
				res[i][j] = 'R'
			else:
				res[i][j] = 'W'
	for i in range(n):
		for j in range(m):
			if (j + i + 1) % 2 == 0:
				ans[i][j] = 'R'
			else:
				ans[i][j] = 'W'
	(flag, falg) = (1, 1)
	for i in range(n):
		for j in range(m):
			if l[i][j] == '.':
				pass
			elif l[i][j] != res[i][j]:
				falg = 0
				break
	for i in range(n):
		for j in range(m):
			if l[i][j] == '.':
				pass
			elif l[i][j] != ans[i][j]:
				flag = 0
				break
	if flag == 0 and falg == 0:
		print('NO')
	else:
		print('YES')
		if falg:
			for i in res:
				print(listToString(i))
		else:
			for i in ans:
				print(listToString(i))


for _ in range(int(input())):
	(m, n) = map(int, input().split())
	a = []
	b = []
	c = []
	d = []
	g = 1
	for j in range(m):
		s = list(input())
		for i in range(n):
			if s[i] == 'R':
				a.append(j)
				b.append(i)
				f = i
				h = j
			elif s[i] == 'W':
				c.append(j)
				d.append(i)
				o = i
				p = j
	A = len(a)
	C = len(c)
	if A > 1:
		for i in range(A - 1):
			if (a[i] - a[i + 1]) % 2 == 0 and (b[i] - b[i + 1]) % 2 == 0 or ((a[i] - a[i + 1]) % 2 != 0 and (b[i] - b[i + 1]) % 2 != 0):
				continue
			else:
				g = 0
	if C > 1:
		for i in range(C - 1):
			if (c[i] - c[i + 1]) % 2 == 0 and (d[i] - d[i + 1]) % 2 == 0 or ((c[i] - c[i + 1]) % 2 != 0 and (d[i] - d[i + 1]) % 2 != 0):
				continue
			else:
				g = 0
	if A < 1 and C < 1:
		print('YES')
		for j in range(m):
			for i in range(n):
				if i % 2 == 1 and j % 2 == 0 or (i % 2 == 0 and j % 2 == 1):
					print('R', end='')
				else:
					print('W', end='')
			print()
		g = 4
	if g == 1:
		if A > 0 and C < 1:
			print('YES')
			for j in range(m):
				for i in range(n):
					if i % 2 == f % 2 and j % 2 == h % 2 or (i % 2 != f % 2 and j % 2 != h % 2):
						print('R', end='')
					else:
						print('W', end='')
				print()
		elif C > 0 and A < 1:
			print('YES')
			for j in range(m):
				for i in range(n):
					if i % 2 == o % 2 and j % 2 == p % 2 or (i % 2 != o % 2 and j % 2 != p % 2):
						print('W', end='')
					else:
						print('R', end='')
				print()
		elif (a[0] - c[0]) % 2 == 0 and (b[0] - d[0]) % 2 == 1 or ((a[0] - c[0]) % 2 == 1 and (b[0] - d[0]) % 2 == 0):
			print('YES')
			for j in range(m):
				for i in range(n):
					if i % 2 == f % 2 and j % 2 == h % 2 or (i % 2 != f % 2 and j % 2 != h % 2):
						print('R', end='')
					else:
						print('W', end='')
				print()
		else:
			print('NO')
	elif g == 0:
		print('NO')


t = int(input())

def fn(m, o):
	arr = ''
	if o:
		for i in range(m):
			if o == 1:
				arr += 'W'
				o = 0
			else:
				arr += 'R'
				o = 1
	else:
		for i in range(m):
			if o == 0:
				arr += 'R'
				o = 1
			else:
				arr += 'W'
				o = 0
	return arr
for _ in range(t):
	(n, m) = map(int, input().split())
	arr = []
	for i in range(n):
		arr.append(input())
	k = 0
	for i in range(n):
		for j in range(m):
			if arr[i][j] == 'R':
				if (i + j) % 2:
					k = 1
				else:
					k = 0
				break
			if arr[i][j] == 'W':
				if (i + j) % 2:
					k = 0
				else:
					k = 1
				break
	ans = []
	for i in range(n):
		ans.append(fn(m, k))
		if k:
			k = 0
		else:
			k = 1
	l = []
	b = 1
	for i in range(n):
		for j in range(m):
			if arr[i][j] == 'R' and ans[i][j] != 'R':
				b = 0
			if arr[i][j] == 'W' and ans[i][j] != 'W':
				b = 0
	if b:
		print('YES')
		for i in range(n):
			print(ans[i])
	else:
		print('NO')


def solve():
	(n, m) = [int(x) for x in input().split()]
	grid = []
	ans1 = []
	ans2 = []
	for i in range(n):
		grid.append(input())
		ans1.append([c for c in grid[i]])
		ans2.append([c for c in grid[i]])
	for i in range(n):
		for j in range(m):
			if (i + j) % 2 == 0:
				ans1[i][j] = 'R'
				ans2[i][j] = 'W'
			else:
				ans1[i][j] = 'W'
				ans2[i][j] = 'R'
	a1 = True
	a2 = True
	for i in range(n):
		for j in range(m):
			if grid[i][j] != '.':
				if grid[i][j] != ans1[i][j]:
					a1 = False
				if grid[i][j] != ans2[i][j]:
					a2 = False
	if not a1 and (not a2):
		print('NO')
		return
	if a1:
		print('YES')
		for x in ans1:
			print(*x, sep='')
		return
	else:
		print('YES')
		for x in ans2:
			print(*x, sep='')
		return

def main():
	for case in range(int(input())):
		solve()
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import sys
from collections import *
input = sys.stdin.readline
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	g = []
	for i in range(n):
		g.append(list(input()))
	r = -1
	ok = True
	for i in range(n):
		for j in range(m):
			if g[i][j] == 'R':
				v = i + j & 1
				if r != -1 and r != v:
					print('NO')
					ok = False
					break
				r = v
			elif g[i][j] == 'W':
				v = 1 - (i + j & 1)
				if r != -1 and r != v:
					print('NO')
					ok = False
					break
				r = v
		if not ok:
			break
	if not ok:
		continue
	if r == -1:
		r = 0
	print('YES')
	for i in range(n):
		for j in range(m):
			if r == i + j & 1:
				print('R', end='')
			else:
				print('W', end='')
		print()


tests = int(input())
for _ in range(tests):
	(n, m) = list(map(int, input().split()))
	rw = -1
	res = True
	for i in range(n):
		s = list(input())
		if not res:
			continue
		for j in range(m):
			if not res:
				break
			if s[j] == 'R':
				if rw == -1:
					rw = i + j & 1
				elif rw != i + j & 1:
					res = False
					break
			elif s[j] == 'W':
				if rw == -1:
					rw = i + j + 1 & 1
				elif rw != i + j + 1 & 1:
					res = False
					break
	if not res:
		print('NO')
	else:
		if rw == -1:
			rw = 0
		print('YES')
		for i in range(n):
			print(''.join([['R', 'W'][j + i + 1 & 1 == rw] for j in range(m)]))


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l1 = []
	l2 = []
	l3 = []
	for _ in range(n):
		l3.append(input())
	for i in range(n):
		s1 = s2 = ''
		for j in range(m):
			if i % 2 == 0 and j % 2 == 0 or (i % 2 != 0 and j % 2 != 0):
				s1 += 'R'
				s2 += 'W'
			else:
				s1 += 'W'
				s2 += 'R'
		l1.append(s1)
		l2.append(s2)
	bool1 = bool2 = True
	for i in range(n):
		for j in range(m):
			if l3[i][j] != '.':
				if l3[i][j] == l2[i][j]:
					bool2 = bool2 and True
				else:
					bool2 = bool2 and False
				if l3[i][j] == l1[i][j]:
					bool1 = bool1 and True
				else:
					bool1 = bool1 and False
	if bool1 == bool2 == False:
		print('NO')
	elif bool1 or (bool1 and bool2):
		print('YES')
		for i in range(n):
			print(l1[i])
	elif bool2:
		print('YES')
		for i in range(n):
			print(l2[i])


I = input
for _ in [0] * int(I()):
	s = set()
	(n, m) = map(int, I().split())
	i = 5
	for _ in [0] * n:
		i ^= 5
		j = 5
		for x in I():
			j ^= 5
			s |= (s, {ord(x) ^ i ^ j})[x > '.']
	if len(s) < 2:
		c = s and s.pop() or 82
		r = ('YES', *(''.join((chr(c ^ ((i ^ j) & 1) * 5) for i in range(m))) for j in range(n)))
	else:
		r = ('NO',)
	print(*r)


for t in range(int(input())):
	(n, m) = map(int, input().split())
	l = []
	for i in range(n):
		l1 = list(input())
		l.append(l1)
	i = 0
	f = True
	while i < n and f:
		j = 0
		while j < m:
			if (i + j) % 2 != 0:
				if l[i][j] == 'W':
					f = False
					break
			elif l[i][j] == 'R':
				f = False
				break
			j += 1
		i += 1
	if f:
		print('YES')
		for i in range(n):
			for j in range(m):
				if (i + j) % 2 != 0:
					print('R', end='')
				else:
					print('W', end='')
			print()
		continue
	f = True
	i = 0
	while i < n and f:
		j = 0
		while j < m:
			if (i + j) % 2:
				if l[i][j] == 'R':
					f = False
					break
			elif l[i][j] == 'W':
				f = False
				break
			j += 1
		i += 1
	if f:
		print('YES')
		for i in range(n):
			for j in range(m):
				if (i + j) % 2:
					print('W', end='')
				else:
					print('R', end='')
			print()
		continue
	if not f:
		print('NO')


def solve():
	nm = list(map(int, input().split()))
	r = nm[0]
	c = nm[1]
	matrix = []
	for i in range(r):
		row = list(input())
		matrix.append(row)
	first = None
	for i in range(r):
		if first:
			break
		for j in range(c):
			if matrix[i][j] == '.':
				continue
			if matrix[i][j] == 'R':
				if j % 2 + i % 2 == 1:
					first = 'W'
				else:
					first = 'R'
				break
			if matrix[i][j] == 'W':
				if j % 2 + i % 2 == 1:
					first = 'R'
				else:
					first = 'W'
				break
	if first == 'R':
		for i in range(r):
			for j in range(c):
				if matrix[i][j] == '.':
					continue
				if matrix[i][j] == 'R':
					if i % 2 + j % 2 == 1:
						print('NO')
						return
				if matrix[i][j] == 'W':
					if i % 2 + j % 2 != 1:
						print('NO')
						return
	if first == 'W':
		for i in range(r):
			for j in range(c):
				if matrix[i][j] == '.':
					continue
				if matrix[i][j] == 'W':
					if i % 2 + j % 2 == 1:
						print('NO')
						return
				if matrix[i][j] == 'R':
					if i % 2 + j % 2 != 1:
						print('NO')
						return
	print('YES')
	if not first or first == 'R':
		for i in range(r):
			for j in range(c):
				if i % 2 + j % 2 == 1:
					print('W', end='')
				else:
					print('R', end='')
			print()
	else:
		for i in range(r):
			for j in range(c):
				if i % 2 + j % 2 == 1:
					print('R', end='')
				else:
					print('W', end='')
			print()
	return
t = int(input())
for i in range(t):
	solve()


def solve():
	(n, m) = map(int, input().split())
	l = []
	for _ in range(n):
		s = input()
		l1 = []
		for i in s:
			if i == 'R':
				l1.append(1)
			elif i == 'W':
				l1.append(0)
			else:
				l1.append(-1)
		l.append(l1)
	ans1 = []
	for i in range(n):
		l1 = []
		if i % 2 == 0:
			for j in range(m):
				if j % 2 == 0:
					l1.append(1)
				else:
					l1.append(0)
		else:
			for j in range(m):
				if j % 2 == 0:
					l1.append(0)
				else:
					l1.append(1)
		ans1.append(l1)
	ans2 = []
	for i in range(n):
		l1 = []
		if i % 2 == 0:
			for j in range(m):
				if j % 2 == 0:
					l1.append(0)
				else:
					l1.append(1)
		else:
			for j in range(m):
				if j % 2 == 0:
					l1.append(1)
				else:
					l1.append(0)
		ans2.append(l1)
	fir = True
	for i in range(n):
		for j in range(m):
			if l[i][j] != -1 and l[i][j] != ans1[i][j]:
				fir = False
				break
	if fir:
		print('YES')
		for i in range(n):
			for j in range(m):
				if ans1[i][j] == 1:
					print('R', end='')
				else:
					print('W', end='')
			print()
		return
	sec = True
	for i in range(n):
		for j in range(m):
			if l[i][j] != -1 and l[i][j] != ans2[i][j]:
				sec = False
				break
	if sec:
		print('YES')
		for i in range(n):
			for j in range(m):
				if ans2[i][j] == 1:
					print('R', end='')
				else:
					print('W', end='')
			print()
		return
	print('NO')
for _ in range(int(input())):
	solve()


t = int(input())
for _ in range(t):
	inp = input().split()
	(n, m) = (int(inp[0]), int(inp[1]))
	(matrix, dots, rind, wind) = ([], 0, None, None)
	for i in range(n):
		row = list(input())
		if not rind and 'R' in row:
			rind = (i, row.index('R'))
		if not wind and 'W' in row:
			wind = (i, row.index('W'))
		matrix.append(row)
	(starter, res) = ('', 'YES')
	if rind:
		starter = 'W' if (rind[0] % 2 == 0) ^ (rind[1] % 2 == 0) else 'R'
	elif wind:
		starter = 'W' if not (wind[0] % 2 == 0) ^ (wind[1] % 2 == 0) else 'R'
	else:
		starter = 'R'
	for i in range(n):
		for j in range(m):
			if matrix[i][j] != '.' and matrix[i][j] != starter:
				res = 'NO'
				break
			else:
				matrix[i][j] = starter
			starter = 'R' if starter == 'W' else 'W'
		if m % 2 == 0:
			starter = 'R' if starter == 'W' else 'W'
		if res == 'NO':
			break
	print(res)
	if res == 'YES':
		for i in range(n):
			for j in range(m):
				print(matrix[i][j], end='')
			print()


from collections import Counter, deque
from itertools import accumulate, product, groupby
import operator
import math
from functools import reduce

def solve():
	(R, C) = [int(char) for char in input().split()]
	board = []
	for r in range(R):
		row = [char for char in input()]
		board.append(row)
	(w1, w2) = (False, False)
	for x in range(R):
		for y in range(C):
			if board[x][y] != '.':
				if (board[x][y] == 'W') == ((x + y) % 2 == 0):
					w1 = True
				else:
					w2 = True
	if w1 and w2:
		print('NO')
		return
	else:
		print('YES')
		if w1:
			for x in range(R):
				line = ''
				for y in range(C):
					line += 'W' if (x + y) % 2 == 0 else 'R'
				print(line)
		else:
			for x in range(R):
				line = ''
				for y in range(C):
					line += 'R' if (x + y) % 2 == 0 else 'W'
				print(line)
for _ in range(int(input())):
	solve()


import os
import sys
from io import BytesIO, IOBase
from copy import deepcopy

def solve():
	(n, m) = map(int, input().split())
	a = [list(input().rstrip()) for _ in range(n)]
	b = deepcopy(a)
	z = sum((i.count('.') for i in a))
	if z == n * m:
		print('YES')
		for i in range(n):
			if i & 1:
				print('RW' * (m // 2) + 'R' * (m % 2))
			else:
				print('WR' * (m // 2) + 'W' * (m % 2))
		return
	x = [1, -1, 0, 0]
	y = [0, 0, -1, 1]
	for i in range(n):
		for j in range(m):
			if a[i][j] == 'R':
				for k in range(4):
					(xx, yy) = (i + x[k], j + y[k])
					if xx >= 0 and xx < n and (yy >= 0) and (yy < m):
						if a[xx][yy] == 'R':
							print('NO')
							return
						a[xx][yy] = 'W'
	for i in range(n):
		for j in range(m):
			if a[i][j] == 'W':
				for k in range(4):
					(xx, yy) = (i + x[k], j + y[k])
					if xx >= 0 and xx < n and (yy >= 0) and (yy < m):
						if a[xx][yy] == 'W':
							print('NO')
							return
						a[xx][yy] = 'R'
	for i in range(n):
		for j in range(m - 1):
			if a[i][j] == 'R':
				a[i][j + 1] = 'W'
			elif a[i][j] == 'W':
				a[i][j + 1] = 'R'
		for j in range(m - 1, 0, -1):
			if a[i][j] == 'R':
				a[i][j - 1] = 'W'
			elif a[i][j] == 'W':
				a[i][j - 1] = 'R'
	for j in range(m):
		for i in range(n - 1):
			if a[i][j] == 'R':
				a[i + 1][j] = 'W'
			elif a[i][j] == 'W':
				a[i + 1][j] = 'R'
		for i in range(n - 1, 0, -1):
			if a[i][j] == 'R':
				a[i - 1][j] = 'W'
			elif a[i][j] == 'W':
				a[i - 1][j] = 'R'
	for i in range(n):
		for j in range(m):
			if b[i][j] != '.' and b[i][j] != a[i][j]:
				print('NO')
				return
	print('YES')
	for i in a:
		print(''.join(i))

def main():
	for _ in range(int(input())):
		solve()
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from sys import stdin, stdout
from math import *
from collections import *

def main():
	(n, m) = [int(x) for x in stdin.readline().split()]
	a = []
	for i in range(n):
		a.append(stdin.readline().strip())
	for s in [['W', 'R'], ['R', 'W']]:
		check = True
		for i in range(n):
			for j in range(m):
				if a[i][j] == '.' or a[i][j] == s[(i + j) % 2]:
					continue
				else:
					check = False
		if check == True:
			stdout.write('YES\n')
			for i in range(n):
				for j in range(m):
					stdout.write(s[(i + j) % 2])
				stdout.write('\n')
			return 0
	stdout.write('NO\n')
	return 0
ntest = int(stdin.readline())
for test in range(ntest):
	main()


lines = int(input())

def print_matrix(matrix, R, C):
	for i in range(R):
		for j in range(C):
			print(matrix[i][j], end='')
		print()
for i in range(lines):
	Ri = []
	Wi = []
	(rows, cols) = [int(x) for x in input().split()]
	for i in range(rows):
		a = []
		a[:0] = input()
		for j in range(len(a)):
			if a[j] == 'R':
				Ri.append([i, j])
			elif a[j] == 'W':
				Wi.append([i, j])
			else:
				continue
	matrix = [[0 for i in range(cols)] for j in range(rows)]
	if len(Ri) != 0 or len(Wi) != 0:
		if len(Ri) != 0:
			idx = Ri[0]
			if (idx[0] + idx[1]) % 2 == 0:
				for i in range(rows):
					for j in range(cols):
						if (i + j) % 2 == 0:
							matrix[i][j] = 'R'
						else:
							matrix[i][j] = 'W'
			else:
				for i in range(rows):
					for j in range(cols):
						if (i + j) % 2 == 0:
							matrix[i][j] = 'W'
						else:
							matrix[i][j] = 'R'
		else:
			idx = Wi[0]
			if (idx[0] + idx[1]) % 2 == 0:
				for i in range(rows):
					for j in range(cols):
						if (i + j) % 2 == 0:
							matrix[i][j] = 'W'
						else:
							matrix[i][j] = 'R'
			else:
				for i in range(rows):
					for j in range(cols):
						if (i + j) % 2 == 0:
							matrix[i][j] = 'R'
						else:
							matrix[i][j] = 'W'
		ans = 'YES'
		for x in Ri:
			if matrix[x[0]][x[1]] == 'R':
				continue
			else:
				ans = 'NO'
				break
		if ans == 'YES':
			for x in Wi:
				if matrix[x[0]][x[1]] != 'W':
					ans = 'NO'
					break
				else:
					continue
	else:
		ans = 'YES'
		for i in range(rows):
			for j in range(cols):
				if (i + j) % 2 == 0:
					matrix[i][j] = 'R'
				else:
					matrix[i][j] = 'W'
	if ans == 'YES':
		print(ans)
		print_matrix(matrix, rows, cols)
	else:
		print(ans)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	mat = []
	for i in range(n):
		mat.append(list(input()))
	ans0 = [[''] * m for i in range(n)]
	ans1 = [[''] * m for i in range(n)]
	for i in range(n):
		for j in range(m):
			if (i + j) % 2 == 0:
				ans0[i][j] = 'R'
			else:
				ans0[i][j] = 'W'
	for i in range(n):
		for j in range(m):
			if (i + j) % 2 == 0:
				ans1[i][j] = 'W'
			else:
				ans1[i][j] = 'R'
	flag0 = 0
	flag1 = 0

	def check(mat, ans0, ans1):
		for i in range(n):
			for j in range(m):
				if mat[i][j] == 'R':
					if ans0[i][j] != 'R' and ans1[i][j] != 'R':
						return 'NO'
					elif ans0[i][j] == 'R':
						return 'flag0'
					elif ans1[i][j] == 'R':
						return 'flag1'
				elif mat[i][j] == 'W':
					if ans0[i][j] != 'W' and ans1[i][j] != 'W':
						return 'NO'
					elif ans0[i][j] == 'W':
						return 'flag0'
					elif ans1[i][j] == 'W':
						return 'flag1'
	x = check(mat, ans0, ans1)
	flag2 = 0
	if x == 'NO':
		flag2 = 1
	elif x == 'flag0':
		for i in range(n):
			for j in range(m):
				if mat[i][j] == 'R':
					if ans0[i][j] != 'R':
						flag2 = 1
						break
				elif mat[i][j] == 'W':
					if ans0[i][j] != 'W':
						flag2 = 1
						break
	else:
		for i in range(n):
			for j in range(m):
				if mat[i][j] == 'R':
					if ans1[i][j] != 'R':
						flag2 = 1
						break
				elif mat[i][j] == 'W':
					if ans1[i][j] != 'W':
						flag2 = 1
						break
	if flag2 == 0:
		print('YES')
		if x == 'flag0':
			for i in range(n):
				print(*ans0[i], sep='')
		else:
			for i in range(n):
				print(*ans1[i], sep='')
	else:
		print('NO')


for t in range(int(input())):
	(n, m) = map(int, input().split())
	k = []
	l = []
	l3 = []
	l1 = 'RW'
	l2 = 'WR'
	ll1 = 0
	ll2 = 0
	for i in range(n):
		k.append(input())
	for i in range((n + 1) // 2):
		k1 = l1 * m
		k2 = l2 * m
		l.append(k1[:m])
		l.append(k2[:m])
		l3.append(k2[:m])
		l3.append(k1[:m])
	for i in range(n):
		for j in range(m):
			if k[i][j] == '.':
				continue
			else:
				if k[i][j] == 'R':
					if l[i][j] != 'R' and ll1 == 0:
						ll1 = -1
					if l3[i][j] != 'R' and ll2 == 0:
						ll2 = -1
				if k[i][j] == 'W':
					if l[i][j] != 'W' and ll1 == 0:
						ll1 = -1
					if l3[i][j] != 'W' and ll2 == 0:
						ll2 = -1
	if ll1 == -1 and ll2 == -1:
		print('NO')
	elif ll1 == 0:
		print('YES')
		for i in range(n):
			print(l[i])
	else:
		print('YES')
		for i in range(n):
			print(l3[i])


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = [list(input()) for i in range(n)]
	mat1 = []
	for i in range(n):
		r = []
		for j in range(m):
			if (i + j) % 2 == 0:
				r.append('W')
			else:
				r.append('R')
		mat1.append(r)
	mat2 = []
	for i in range(n):
		r = []
		for j in range(m):
			if (i + j) % 2:
				r.append('W')
			else:
				r.append('R')
		mat2.append(r)
	f = 1
	for i in range(n):
		for j in range(m):
			if mat1[i][j] == 'R' and (l[i][j] == 'R' or l[i][j] == '.'):
				pass
			elif mat1[i][j] == 'W' and (l[i][j] == 'W' or l[i][j] == '.'):
				pass
			else:
				f = 0
				break
	if f == 0:
		f = 1
		for i in range(n):
			for j in range(m):
				if mat2[i][j] == 'R' and (l[i][j] == 'R' or l[i][j] == '.'):
					pass
				elif mat2[i][j] == 'W' and (l[i][j] == 'W' or l[i][j] == '.'):
					pass
				else:
					f = 0
					break
		if f == 0:
			print('NO')
		else:
			print('YES')
			for i in mat2:
				print(''.join(i))
	else:
		print('YES')
		for i in mat1:
			print(''.join(i))


import sys
from sys import stdin, stdout
(input, print) = (stdin.readline, stdout.write)
from collections import OrderedDict, defaultdict
import bisect
import math
n = 0
m = 0

def valid(x, y):
	global n, m
	return x >= 0 and y >= 0 and (x < n) and (y < m)
t = int(input())
while t > 0:
	t -= 1
	(n, m) = [int(x) for x in input().split()]
	mat = []
	for i in range(n):
		mat.append(list(input()))
	a = []
	b = []
	for i in range(n):
		s = []
		ss = []
		for j in range(m):
			if (i + j) % 2 == 0:
				s.append('R')
				ss.append('W')
			else:
				s.append('W')
				ss.append('R')
		a.append(s)
		b.append(ss)
	pa = True
	pb = True
	for i in range(n):
		for j in range(m):
			if mat[i][j] == '.':
				continue
			if mat[i][j] != a[i][j]:
				pa = False
			if mat[i][j] != b[i][j]:
				pb = False
	if pa:
		print('YES\n')
		for i in range(n):
			print(''.join(map(str, a[i])))
			print('\n')
	elif pb:
		print('YES\n')
		for i in range(n):
			print(''.join(map(str, b[i])))
			print('\n')
	else:
		print('NO\n')


from collections import defaultdict

def check(g1, g2):
	ans = True
	for i in range(n):
		for j in range(m):
			if not (g1[i][j] == '.' or g1[i][j] == g2[i][j]):
				ans = False
				break
		if not ans:
			break
	return ans
for i in range(int(input())):
	(n, m) = map(int, input().split())
	visited = [[False for j in range(m)] for jk in range(n)]
	grid = []
	for j in range(n):
		a = list(input())
		grid.append(a)
	ans1 = []
	rw = []
	for j in range(m):
		if j % 2 == 0:
			rw.append('R')
		else:
			rw.append('W')
	wr = []
	for j in range(m):
		if j % 2 != 0:
			wr.append('R')
		else:
			wr.append('W')
	ans1 = []
	for j in range(n):
		if j % 2 == 0:
			ans1.append(rw)
		else:
			ans1.append(wr)
	ans2 = []
	for j in range(n):
		if j % 2 != 0:
			ans2.append(rw)
		else:
			ans2.append(wr)
	if check(grid, ans1):
		print('YES')
		for j in ans1:
			print(''.join(j))
	elif check(grid, ans2):
		print('YES')
		for j in ans2:
			print(''.join(j))
	else:
		print('NO')


from __future__ import print_function
from collections import *
from sys import stdin
from heapq import *
from math import *
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
rr = lambda x: reversed(range(x))
mod = int(1000000000.0) + 7
inf = float('inf')
direction = [(1, 0), (0, 1), (-1, 0), (0, -1)]
for _ in range(gil()[0]):
	(n, m) = gil()
	mat = []
	st = []
	for i in range(n):
		j = 0
		mat.append([])
		for ch in g():
			mat[-1].append(ch)
			if ch != '.':
				st.append((i, j))
			j += 1
	ans = 'YES'
	if len(st) == 0:
		st.append((0, 0))
		mat[0][0] = 'R'
	while ans == 'YES' and st:
		(i, j) = st.pop()
		to = 'R' if mat[i][j] == 'W' else 'W'
		for (di, dj) in direction:
			(ni, nj) = (i + di, j + dj)
			if ni < 0 or ni >= n or nj < 0 or (nj >= m):
				continue
			if mat[ni][nj] == '.':
				st.append((ni, nj))
				mat[ni][nj] = to
			elif mat[ni][nj] != to:
				ans = 'NO'
				break
	if ans == 'YES':
		for i in range(n):
			if ans == 'NO':
				break
			for j in range(m):
				to = 'R' if mat[i][j] == 'W' else 'W'
				for (di, dj) in direction:
					(ni, nj) = (i + di, j + dj)
					if ni < 0 or ni == n or nj < 0 or (nj == m):
						continue
					if mat[ni][nj] != to:
						ans = 'NO'
					break
	print(ans)
	if ans == 'YES':
		for r in mat:
			print(''.join(r))


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	arr = [list(input()) for i in range(n)]
	k = -1
	for i in range(n):
		if 'R' in arr[i] or 'W' in arr[i]:
			k = i
			break
	if k == -1:
		arr[0][0] = 'R'
		k = 0
	for i in range(k, n):
		x = []
		for j in range(m):
			if arr[i][j] != '.':
				x.append(j)
		if not x:
			if i > 0:
				if arr[i - 1][j] == 'R':
					arr[i][j] = 'W'
					x.append(j)
				else:
					arr[i][j] = 'R'
					x.append(j)
		while x:
			v = x.pop()
			for j in range(v + 1, m):
				if arr[i][j] == '.':
					if arr[i][j - 1] == 'R':
						arr[i][j] = 'W'
					else:
						arr[i][j] = 'R'
				else:
					break
			for j in range(v - 1, -1, -1):
				if arr[i][j] == '.':
					if arr[i][j + 1] == 'R':
						arr[i][j] = 'W'
					else:
						arr[i][j] = 'R'
	for i in range(k, -1, -1):
		x = []
		for j in range(m):
			if arr[i][j] != '.':
				x.append(j)
		if not x:
			if i < n - 1:
				if arr[i + 1][j] == 'R':
					arr[i][j] = 'W'
					x.append(j)
				else:
					arr[i][j] = 'R'
					x.append(j)
		while x:
			v = x.pop()
			for j in range(v + 1, m):
				if arr[i][j] == '.':
					if arr[i][j - 1] == 'R':
						arr[i][j] = 'W'
					else:
						arr[i][j] = 'R'
				else:
					break
			for j in range(v - 1, -1, -1):
				if arr[i][j] == '.':
					if arr[i][j + 1] == 'R':
						arr[i][j] = 'W'
					else:
						arr[i][j] = 'R'
	b = True
	for i in range(n):
		for j in range(m):
			temp = []
			if i > 0:
				temp.append(arr[i - 1][j])
			if i < n - 1:
				temp.append(arr[i + 1][j])
			if j > 0:
				temp.append(arr[i][j - 1])
			if j < m - 1:
				temp.append(arr[i][j + 1])
			if arr[i][j] == 'R' and 'R' in temp or (arr[i][j] == 'W' and 'W' in temp):
				b = False
				break
	if not b:
		print('NO')
	else:
		print('YES')
		for i in arr:
			print(''.join(i))


import sys
IS_INTERACTIVE = False
input = input
if not IS_INTERACTIVE:
	(*data,) = sys.stdin.read().split('\n')[::-1]

	def input():
		return data.pop()

def fprint(*args, **kwargs):
	print(*args, **kwargs, flush=True)

def eprint(*args, **kwargs):
	print(*args, **kwargs, file=sys.stderr)

def check(t1):
	for i in range(n):
		for j in range(m):
			if t1[i][j] != rows[i][j] and rows[i][j] != '.':
				return False
	return True
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	rows = []
	for _ in range(n):
		rows.append(input())
	t1 = [['j'] * m for _ in range(n)]
	for i in range(n):
		for j in range(m):
			t1[i][j] = 'R' if (i + j) % 2 else 'W'
	if check(t1):
		print('YES')
		for row in t1:
			print(''.join(row))
		continue
	for i in range(n):
		for j in range(m):
			t1[i][j] = 'W' if t1[i][j] == 'R' else 'R'
	if check(t1):
		print('YES')
		for row in t1:
			print(''.join(row))
		continue
	print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	mat1 = [['R' for i in range(m)] for j in range(n)]
	mat2 = [['W' for i in range(m)] for j in range(n)]
	colour1 = 'R'
	colour2 = 'W'
	for i in range(n):
		for j in range(m):
			mat1[i][j] = colour1
			mat2[i][j] = colour2
			colour1 = 'W' if colour1 == 'R' else 'R'
			colour2 = 'W' if colour2 == 'R' else 'R'
		if m % 2 == 0:
			colour1 = 'W' if colour1 == 'R' else 'R'
			colour2 = 'W' if colour2 == 'R' else 'R'
	l = [[] for i in range(n)]
	for i in range(n):
		l[i] = list(input())
	isMatOne = False
	isMatTwo = False
	flag = False
	for i in range(n):
		for j in range(m):
			if l[i][j] == 'R' or l[i][j] == 'W':
				if l[i][j] == mat1[i][j]:
					if isMatTwo:
						flag = True
						break
					isMatOne = True
				elif l[i][j] == mat2[i][j]:
					if isMatOne:
						flag = True
						break
					isMatTwo = True
				else:
					flag = True
					break
		if flag:
			break
	if flag:
		print('NO')
	else:
		print('YES')
		if isMatOne:
			for i in range(n):
				print(''.join(mat1[i]))
		else:
			for i in range(n):
				print(''.join(mat2[i]))


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	str = [input() for i in range(n)]
	s1 = [''.join(('WR'[(i + j) % 2] for j in range(m))) for i in range(n)]
	s2 = [''.join(('WR'[(i + j + 1) % 2] for j in range(m))) for i in range(n)]
	flag = flag1 = True
	x = lambda str, s1: any((a != '.' and a != b for (a, b) in zip(''.join(str), ''.join(s1))))
	flag = x(str, s1)
	flag1 = x(str, s2)
	if not flag or not flag1:
		print('YES')
		if not flag:
			for i in s1:
				print(i)
		else:
			for i in s2:
				print(i)
	else:
		print('NO')


for k in range(int(input())):
	(n, m) = map(int, input().split())
	arr = []
	for i in range(n):
		arr.append(list(input()))
	flag = 0
	t = None
	for i in range(n):
		for j in range(m):
			if arr[i][j] != '.':
				t = (i, j, arr[i][j])
				flag = 1
				break
		if flag:
			break
	if t == None:
		rc = 'W'
		for i in range(n):
			cc = rc
			for j in range(m):
				if arr[i][j] == '.':
					arr[i][j] = cc
				if cc == 'W':
					cc = 'R'
				else:
					cc = 'W'
			if rc == 'W':
				rc = 'R'
			else:
				rc = 'W'
		ans = 'YES'
	else:
		if (t[0] + t[1]) % 2 == 0:
			sc = t[2]
		elif t[2] == 'W':
			sc = 'R'
		else:
			sc = 'W'
		rc = sc
		for i in range(n):
			cc = rc
			for j in range(m):
				if arr[i][j] == '.':
					arr[i][j] = cc
				if cc == 'W':
					cc = 'R'
				else:
					cc = 'W'
			if rc == 'W':
				rc = 'R'
			else:
				rc = 'W'
		flag = 0
		rc = sc
		for i in range(n):
			if arr[i][0] != rc:
				flag = 1
				break
			cc = rc
			for j in range(m):
				if arr[i][j] != cc:
					flag = 1
					break
				if cc == 'W':
					cc = 'R'
				else:
					cc = 'W'
			if flag:
				break
			if rc == 'W':
				rc = 'R'
			else:
				rc = 'W'
		if flag:
			ans = 'NO'
		else:
			ans = 'YES'
	print(ans)
	if ans == 'YES':
		for i in range(n):
			print(''.join(arr[i]))


for _ in [0] * int(input()):
	(n, m) = map(int, input().split())
	w = [input() for i in range(n)]
	s = [('RW' * m)[:m], ('WR' * m)[:m]]

	def check():
		for i in range(n):
			for j in range(m):
				if w[i][j] != '.' and w[i][j] != s[i % 2][j]:
					return False
		else:
			return True
	if check():
		print('YES')
		for i in range(n):
			print(s[i % 2])
	else:
		(s[0], s[1]) = (s[1], s[0])
		if check():
			print('YES')
			for i in range(n):
				print(s[i % 2])
		else:
			print('NO')


import sys

def giveval(i, j):
	if i % 2 == 0 and j % 2 == 0:
		return 0
	if i % 2 == 0 and j % 2 == 1:
		return 1
	if i % 2 == 1 and j % 2 == 0:
		return 1
	if i % 2 == 1 and j % 2 == 1:
		return 0

def solve(n, m, arr):
	R = -2
	W = -2
	for i in range(n):
		for j in range(m):
			if arr[i][j] == 'R':
				if R == -2:
					R = giveval(i, j)
				elif giveval(i, j) != R:
					print('NO')
					return
				if W != -2 and giveval(i, j) == W:
					print('NO')
					return
			if arr[i][j] == 'W':
				if W == -2:
					W = giveval(i, j)
				elif giveval(i, j) != W:
					print('NO')
					return
				if R != -2 and giveval(i, j) == R:
					print('NO')
					return
	if R == -2 and W == -2:
		R = 0
		W = 1
	elif R == -2 and W != -2:
		R = 1 - W
	elif R != -2 and W == -2:
		W = 1 - R
	for i in range(n):
		for j in range(m):
			if giveval(i, j) == R:
				arr[i][j] = 'R'
			elif giveval(i, j) == W:
				arr[i][j] = 'W'
	print('YES')
	for i in range(n):
		for j in range(m):
			print(arr[i][j], end='')
		print()
t = int(sys.stdin.readline())
for i in range(t):
	[n, m] = [int(j) for j in sys.stdin.readline().split()]
	arr = []
	for i in range(n):
		tmp = sys.stdin.readline().strip()
		p = []
		for i in range(m):
			p.append(tmp[i])
		arr.append(p)
	solve(n, m, arr)


import sys
input = sys.stdin.readline

def I():
	return input().strip()

def II():
	return int(input().strip())

def LI():
	return [*map(int, input().strip().split())]
import copy
import string, math, time, functools, random, fractions
from heapq import heappush, heappop, heapify
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter, OrderedDict
from itertools import permutations, combinations, groupby, count, filterfalse
from operator import itemgetter
for _ in range(II()):
	(n, m) = LI()
	l = []
	l2 = []
	s1 = set()
	s2 = set()
	for i in range(n):
		l1 = []
		for j in range(m):
			l1.append((i + j) % 2)
		l2.append(l1)
	for i in range(n):
		l.append(list(I()))
	for i in range(n):
		for j in range(m):
			if l[i][j] == 'R':
				s1.add((i + j) % 2)
			if l[i][j] == 'W':
				s2.add((i + j) % 2)
	s1 = list(s1)
	s2 = list(s2)
	if len(s1) == 0 and len(s2) == 0:
		print('YES')
		for i in range(n):
			for j in range(m):
				if l2[i][j] == 0:
					print('R', end='')
				else:
					print('W', end='')
			print()
		continue
	if len(s1) > 1 or len(s2) > 1:
		print('NO')
		continue
	if s1 == s2:
		print('NO')
		continue
	if len(s1) > 0:
		print('YES')
		if s1[0] == 0:
			for i in range(n):
				for j in range(m):
					if l2[i][j] == 0:
						print('R', end='')
					else:
						print('W', end='')
				print()
		else:
			for i in range(n):
				for j in range(m):
					if l2[i][j] == 0:
						print('W', end='')
					else:
						print('R', end='')
				print()
		continue
	if len(s2) > 0:
		print('YES')
		if s2[0] == 0:
			for i in range(n):
				for j in range(m):
					if l2[i][j] == 0:
						print('W', end='')
					else:
						print('R', end='')
				print()
		else:
			for i in range(n):
				for j in range(m):
					if l2[i][j] == 0:
						print('R', end='')
					else:
						print('W', end='')
				print()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = [list(input()) for i in range(n)]
	re = False
	isTrue = False
	for i in range(n):
		for j in range(m):
			if s[i][j] == 'R':
				if (i + j) % 2 == 0:
					re = True
					isTrue = True
					break
			elif s[i][j] == 'W':
				if (i + j) % 2 == 1:
					re = True
					isTrue = True
					break
		if isTrue:
			break
	ans = 'YES'
	isTrue = False
	if re:
		for i in range(n):
			for j in range(m):
				if (i + j) % 2 == 0:
					if s[i][j] == 'W':
						ans = 'NO'
						isTrue = True
						break
					s[i][j] = 'R'
				else:
					if s[i][j] == 'R':
						ans = 'NO'
						isTrue = True
						break
					s[i][j] = 'W'
			if isTrue:
				break
	else:
		for i in range(n):
			for j in range(m):
				if (i + j) % 2 == 0:
					if s[i][j] == 'R':
						ans = 'NO'
						isTrue = True
						break
					s[i][j] = 'W'
				else:
					if s[i][j] == 'W':
						ans = 'NO'
						isTrue = True
						break
					s[i][j] = 'R'
			if isTrue:
				break
	print(ans)
	if ans == 'YES':
		for i in range(n):
			print(''.join(s[i]))


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	matrix = [[x for x in input()] for _ in range(n)]
	r = c = -1
	for i in range(n):
		for j in range(m):
			if matrix[i][j] == 'R':
				(r, c) = (i, j)
				break
			elif matrix[i][j] == 'W':
				(r, c) = (i, j)
				break
	first = 'W'
	flag = False
	if r >= 0:
		if c % 2 == 0:
			first = matrix[r][c]
		else:
			first = 'R' if matrix[r][c] == 'W' else 'W'
		if r % 2 != 0:
			first = 'R' if first == 'W' else 'W'
	for i in range(n):
		for j in range(m):
			if matrix[i][j] == first or matrix[i][j] == '.':
				matrix[i][j] = first
				first = 'W' if first == 'R' else 'R'
			else:
				flag = True
				break
		first = 'W' if matrix[i][0] == 'R' else 'R'
	if flag:
		print('NO')
	else:
		print('YES')
		for i in matrix:
			print(''.join(i))


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	ar = []
	for i in range(n):
		a = list(str(input()))
		ar.append(a)
	flag = 0
	if n == 1 and m == 1:
		if ar[n - 1][m - 1] == '.':
			ar[n - 1][m - 1] = 'R'
		a = ar[0]
		print('YES')
		print(*a, sep='')
	else:
		f2 = 0
		row = 0
		col = 0
		el = 'R'
		for i in range(n):
			for j in range(m):
				if ar[i][j] != '.':
					row = i
					col = j
					el = ar[i][j]
					f2 = 1
					break
			if f2 == 1:
				break
		if f2 == 1:
			for i in range(n):
				for j in range(m):
					if ar[i][j] != '.':
						if (i + j) % 2 == (row + col) % 2:
							if el != ar[i][j]:
								flag = 1
								break
						elif el == ar[i][j]:
							flag = 1
							break
				if flag == 1:
					break
		if flag == 1:
			print('NO')
		else:
			print('YES')
			for i in range(n):
				for j in range(m):
					if (i + j) % 2 == (row + col) % 2:
						ar[i][j] = el
					elif el == 'R':
						ar[i][j] = 'W'
					else:
						ar[i][j] = 'R'
			for i in range(n):
				a = ar[i]
				print(*a, sep='')


def solve():
	(n, m) = map(int, input().split())
	grid = [list(input()) for i in range(n)]
	l = ('R', 'W')
	grid1 = [[l[(i + j) % 2] for i in range(m)] for j in range(n)]
	grid2 = [[l[(i + j + 1) % 2] for i in range(m)] for j in range(n)]
	(g1, g2) = (False, False)
	ind = 0
	for line in range(n):
		for ch in range(m):
			if grid[line][ch] == grid1[line][ch]:
				g1 = True
			if grid[line][ch] == grid2[line][ch]:
				g2 = True
	if g1 and g2:
		print('NO')
	elif g1:
		print('YES')
		for line in range(n):
			print(''.join(grid1[line]))
	else:
		print('YES')
		for line in range(n):
			print(''.join(grid2[line]))
t = int(input())
for _ in range(t):
	solve()


from sys import *
from collections import defaultdict as dd
from math import *
from bisect import *

def sinp():
	return input()

def inp():
	return int(sinp())

def minp():
	return map(int, sinp().split())

def linp():
	return list(minp())

def strl():
	return list(sinp())

def pr(x):
	print(x)
mod = int(1000000000.0 + 7)
for _ in range(inp()):
	(n, m) = minp()
	grid = [list(sinp()) for i in range(n)]
	temp1 = []
	temp2 = []
	for i in range(m):
		if i % 2 == 0:
			temp1.append('R')
			temp2.append('W')
		else:
			temp2.append('R')
			temp1.append('W')
	grid1 = []
	grid2 = []
	for i in range(n):
		if not i & 1:
			grid1.append(temp1)
			grid2.append(temp2)
		else:
			grid2.append(temp1)
			grid1.append(temp2)
	i = 0
	f = False
	while i < n and (not f):
		for j in range(m):
			if grid[i][j] != '.' and grid[i][j] != grid2[i][j]:
				f = True
				break
		i += 1
	if not f:
		pr('YES')
		for i in grid2:
			print(*i, sep='')
		continue
	f = False
	i = 0
	while i < n and (not f):
		for j in range(m):
			if grid[i][j] != '.' and grid[i][j] != grid1[i][j]:
				f = True
				break
		i += 1
	if not f:
		pr('YES')
		for i in grid1:
			print(*i, sep='')
		continue
	pr('NO')


import sys
input = lambda : sys.stdin.readline()
int_arr = lambda : list(map(int, input().split()))
str_arr = lambda : list(map(str, input().split()))
get_str = lambda : map(str, input().split())
get_int = lambda : map(int, input().split())
get_flo = lambda : map(float, input().split())

def R(arr):
	a = []
	f1 = True
	for i in range(len(arr)):
		temp = ''
		for j in range(len(arr[0])):
			if i % 2 == 0:
				if j % 2 == 0:
					s = 'R'
				else:
					s = 'W'
			elif j % 2 == 0:
				s = 'W'
			else:
				s = 'R'
			if arr[i][j] == '.' or s == arr[i][j]:
				temp += s
			elif arr[i][j] != '.' and s != arr[i][j]:
				f1 = False
				return 0
		a.append(temp)
	if f1:
		return a

def W(arr):
	b = []
	f2 = True
	for i in range(len(arr)):
		temp = ''
		for j in range(len(arr[0])):
			if i % 2 == 0:
				if j % 2 == 0:
					s = 'W'
				else:
					s = 'R'
			elif j % 2 == 0:
				s = 'R'
			else:
				s = 'W'
			if arr[i][j] == '.' or s == arr[i][j]:
				temp += s
			elif arr[i][j] != '.' and s != arr[i][j]:
				f2 = False
				return 0
		b.append(temp)
	if f2:
		return b

def solve(n, m, arr):
	a = R(arr)
	b = W(arr)
	if a != 0:
		print('YES')
		for i in a:
			for j in i:
				print(j, end='')
			print()
	elif b != 0:
		print('YES')
		for i in b:
			for j in i:
				print(j, end='')
			print()
	else:
		print('NO')
for _ in range(int(input())):
	(n, m) = get_int()
	arr = []
	for i in range(n):
		s = str(input())
		arr.append(s[:-1])
	solve(n, m, arr)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	daf = []
	red = set()
	white = set()
	for i in range(x):
		daf.append(list(input()))
	for i in range(x):
		for j in range(y):
			if daf[i][j] == 'R':
				red.add((i + j) % 2)
			elif daf[i][j] == 'W':
				white.add((i + j) % 2)
	if red == white and len(red) == 1 or len(red) > 1 or len(white) > 1:
		print('NO')
		continue
	print('YES')
	if white == {1} or red == {0}:
		par = ('R', 'W')
	else:
		par = ('W', 'R')
	for i in range(x):
		for j in range(y):
			daf[i][j] = par[(i + j) % 2]
	for i in range(x):
		print(''.join(daf[i]))


import math
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	arr = []
	for i in range(n):
		arr.append(input())
	st = ''
	for i in range(m):
		if i % 2 == 0:
			st += 'R'
		else:
			st += 'W'
	st1 = st[1:]
	if m % 2 == 0:
		st1 += 'R'
	else:
		st1 += 'W'
	isst = True
	for i in range(n):
		for j in range(m):
			if arr[i][j] == '.':
				continue
			if i % 2 == 0:
				if arr[i][j] != st[j]:
					isst = False
					break
			elif arr[i][j] != st1[j]:
				isst = False
				break
	isst1 = True
	for i in range(n):
		for j in range(m):
			if arr[i][j] == '.':
				continue
			if i % 2 != 0:
				if arr[i][j] != st[j]:
					isst1 = False
					break
			elif arr[i][j] != st1[j]:
				isst1 = False
				break
	if not (isst1 or isst):
		print('NO')
	else:
		print('YES')
		if isst:
			for i in range(n):
				if i % 2 == 0:
					print(st)
				else:
					print(st1)
		else:
			for i in range(n):
				if i % 2 != 0:
					print(st)
				else:
					print(st1)


def testGrid(grid, rows, cols):
	grid1 = [row[:] for row in grid]
	grid2 = [row[:] for row in grid]
	g1 = True
	g2 = True
	for r in range(rows):
		for c in range(cols):
			if (c + r) % 2 == 0:
				grid1[r][c] = 'W'
				grid2[r][c] = 'R'
			else:
				grid1[r][c] = 'R'
				grid2[r][c] = 'W'
			if grid[r][c] != '.' and grid[r][c] != grid1[r][c]:
				g1 = False
			if grid[r][c] != '.' and grid[r][c] != grid2[r][c]:
				g2 = False
	if g1:
		return 'YES\n' + '\n'.join([''.join(row) for row in grid1])
	elif g2:
		return 'YES\n' + '\n'.join([''.join(row) for row in grid2])
	return 'NO'
tests = int(input())
for test in range(tests):
	dimensions = input().split()
	(m, n) = (int(dimensions[0]), int(dimensions[1]))
	grid = []
	for r in range(m):
		row = input()
		grid.append([c for c in row])
	print(testGrid(grid, m, n))


c = int(input())
while c != 0:

	def display(matrix, R, C):
		for i in range(R):
			for j in range(C):
				print(matrix[i][j], end='')
			print()

	def fun():
		for i in range(R):
			for j in range(C):
				if matrix[i][j] != '.':
					Check(i, j, matrix)
					return
		else:
			Check(0, 0, matrix)
			return

	def Check(i, j, matrix):
		if (i % 2 == 0) ^ (j % 2 == 0):
			if matrix[i][j] == 'W':
				first_R(matrix)
			else:
				first_W(matrix)
		elif matrix[i][j] == 'R':
			first_R(matrix)
		else:
			first_W(matrix)

	def first_R(matrix):
		for i in range(R):
			for j in range(C):
				if (i % 2 == 0) ^ (j % 2 == 0):
					if matrix[i][j] == 'R':
						print('NO')
						return
					if matrix[i][j] == '.':
						matrix[i][j] = 'W'
				else:
					if matrix[i][j] == 'W':
						print('NO')
						return
					if matrix[i][j] == '.':
						matrix[i][j] = 'R'
		print('YES')
		display(matrix, R, C)

	def first_W(matrix):
		for i in range(R):
			for j in range(C):
				if (i % 2 == 0) ^ (j % 2 == 0):
					if matrix[i][j] == 'W':
						print('NO')
						return
					if matrix[i][j] == '.':
						matrix[i][j] = 'R'
				else:
					if matrix[i][j] == 'R':
						print('NO')
						return
					if matrix[i][j] == '.':
						matrix[i][j] = 'W'
		print('YES')
		display(matrix, R, C)
	s1 = input()
	l1 = [int(a) for a in s1.split()]
	R = l1[0]
	C = l1[1]
	matrix = []
	for i in range(R):
		a = []
		s2 = input()
		for j in s2:
			a.append(j)
		matrix.append(a)
	fun()
	c -= 1


import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	grid = []
	for i in range(n):
		temp = input().strip()
		grid.append(temp)
	r = []
	w = []
	for i in range(n):
		for j in range(m):
			if grid[i][j] == 'R':
				r.append([i, j])
			elif grid[i][j] == 'W':
				w.append([i, j])
	tempr = -1
	tempw = -1
	ans = True
	if len(r) > 0:
		tempr = (r[0][0] + r[0][1]) % 2
		for i in range(1, len(r)):
			if (r[i][0] + r[i][1]) % 2 != tempr:
				ans = False
				break
	if len(w) > 0 and ans:
		tempw = (w[0][0] + w[0][1]) % 2
		for i in range(1, len(w)):
			if (w[i][0] + w[i][1]) % 2 != tempw:
				ans = False
				break
	if tempr == -1 and tempw == -1:
		tempr = 1
		tempw = 0
	if tempw == tempr:
		ans = False
	if not ans:
		print('NO')
		continue
	if tempr == -1:
		tempr = 1 - tempw
	if tempw == -1:
		tempw = 1 - tempr
	if ans:
		print('YES')
		for i in range(n):
			for j in range(m):
				if (i + j) % 2 == tempr:
					print('R', end='')
				else:
					print('W', end='')
			print()
		print()


I = input
r = range
for _ in [0] * int(I()):
	(n, m) = map(int, I().split())
	s = {ord(x) ^ ((i ^ j) & 1) * 5 for i in r(n) for (j, x) in enumerate(I()) if '.' < x}
	c = s and s.pop() or 82
	print(*(('YES', *(''.join((chr(c ^ ((i ^ j) & 1) * 5) for i in r(m))) for j in r(n))), ['NO'])[bool(s)])


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	mat = []
	for i in range(n):
		temp = input()
		mat.append([i for i in temp])
	mat1 = [['R' for i in range(m)] for j in range(n)]
	for i in range(n):
		if i & 1:
			for j in range(1, m, 2):
				mat1[i][j] = 'W'
		else:
			for j in range(0, m, 2):
				mat1[i][j] = 'W'
	mat2 = [['W' for i in range(m)] for j in range(n)]
	for i in range(n):
		if i & 1:
			for j in range(1, m, 2):
				mat2[i][j] = 'R'
		else:
			for j in range(0, m, 2):
				mat2[i][j] = 'R'
	first = True
	second = True
	for i in range(n):
		for j in range(m):
			if mat1[i][j] == mat[i][j] or mat[i][j] == '.':
				continue
			else:
				first = False
	for i in range(n):
		for j in range(m):
			if mat2[i][j] == mat[i][j] or mat[i][j] == '.':
				continue
			else:
				second = False
	if first or second:
		print('YES')
		if first:
			for i in range(n):
				print(''.join(mat1[i]))
		else:
			for i in range(n):
				print(''.join(mat2[i]))
	else:
		print('NO')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def scanf(datatype=str):
	return datatype(sys.stdin.readline().rstrip())

def printf(answer=''):
	return sys.stdout.write(str(answer) + '\n')

def prints(answer):
	return sys.stdout.write(str(answer))

def map_input(datatype=str):
	return map(datatype, sys.stdin.readline().split())

def list_input(datatype=str):
	return list(map(datatype, sys.stdin.readline().split()))

def testcase(number: int, solve_function):
	for _ in range(number):
		solve_function()

def solve():
	(n, m) = map_input(int)
	grid = []
	for i in range(n):
		s = scanf()
		grid.append(list(s))
	found = False
	for r in range(2):
		ok = True
		for i in range(n):
			for j in range(m):
				c = 'R' if (i + j + r) % 2 == 0 else 'W'
				if grid[i][j] == c:
					ok = False
		if ok:
			printf('YES')
			for i in range(n):
				for j in range(m):
					c = 'R' if (i + j + r + 1) % 2 == 0 else 'W'
					prints(c)
				printf()
			found = True
			break
	if not found:
		printf('NO')
t = scanf(int)
testcase(t, solve)


import os, sys
from io import BytesIO, IOBase
from collections import deque, Counter, defaultdict as dft
from heapq import heappop, heappush
from math import log, sqrt, factorial, cos, tan, sin, radians, log2, ceil, floor
from bisect import bisect, bisect_left, bisect_right
from decimal import *
import sys, threading
from itertools import permutations, combinations
from copy import deepcopy
input = sys.stdin.readline
ii = lambda : int(input())
si = lambda : input().rstrip()
mp = lambda : map(int, input().split())
ms = lambda : map(str, input().strip().split(' '))
ml = lambda : list(mp())
mf = lambda : map(float, input().split())
alphs = 'abcdefghijklmnopqrstuvwxyz'

def solve():
	(n, m) = mp()
	grid = []
	odd = -1
	eve = -1
	for i in range(n):
		s = input()
		grid.append(s)
	for i in range(n):
		s = grid[i]
		for j in range(m):
			if s[j] == '.':
				continue
			if (i + j) % 2:
				if odd == -1:
					odd = s[j]
				elif odd != s[j]:
					print('NO')
					return
			elif eve == -1:
				eve = s[j]
			elif eve != s[j]:
				print('NO')
				return
	if odd == -1:
		if eve == -1:
			odd = 'R'
			eve = 'W'
		elif eve == 'R':
			odd = 'W'
		else:
			odd = 'R'
	else:
		if eve != -1:
			if odd == eve:
				print('NO')
				return
		if odd == 'R':
			eve = 'W'
		else:
			eve = 'R'
	print('YES')
	for i in range(n):
		for j in range(m):
			if (i + j) % 2:
				print(odd, end='')
			else:
				print(eve, end='')
		print()
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
tc = 1
tc = ii()
for i in range(tc):
	solve()


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	R = []
	W = []
	for i in range(a):
		s = input()
		for j in range(b):
			if s[j] == 'R':
				R.append([i, j])
			elif s[j] == 'W':
				W.append([i, j])
	l = []
	for _ in range(a):
		l.append(['*' for i in range(b)])
	for i in range(a):
		for j in range(b):
			if (i + j) % 2 == 0:
				l[i][j] = 'R'
			else:
				l[i][j] = 'W'
	flag = True
	for i in R:
		if l[i[0]][i[1]] != 'R':
			flag = False
			break
	if flag:
		for i in W:
			if l[i[0]][i[1]] != 'W':
				flag = False
				break
	if flag:
		print('YES')
		for i in l:
			print(''.join(i))
	else:
		flag = True
		for i in range(a):
			for j in range(b):
				if (i + j) % 2 != 0:
					l[i][j] = 'R'
				else:
					l[i][j] = 'W'
		for i in R:
			if l[i[0]][i[1]] != 'R':
				flag = False
				break
		if flag:
			for i in W:
				if l[i[0]][i[1]] != 'W':
					flag = False
					break
		if flag:
			print('YES')
			for i in l:
				print(''.join(i))
		else:
			print('NO')


import sys
import math
mod = 10 ** 9 + 7
i = sys.stdin.readline

def isin(l, x):
	left = 0
	right = len(l) - 1
	while left <= right:
		mid = (left + right) // 2
		if l[mid] == x:
			return mid
		elif l[mid] < x:
			left = mid + 1
		else:
			right = mid - 1
	return -1

def main():
	(n, m) = [int(k) for k in i().split()]
	l = []
	for k in range(n):
		temp = i().strip()
		l.append(temp)
	bool = False
	(s_row, s_col) = (0, 0)
	for row in range(n):
		for col in range(m):
			if l[row][col] == 'R' or l[row][col] == 'W':
				s_row = row
				s_col = col
				ch = l[row][col]
				bool = True
				break
	if bool:
		if ch == 'W':
			if s_col % 2 == 0:
				seed = ('WR' * m)[:m]
				antiseed = ('RW' * m)[:m]
			else:
				seed = ('RW' * m)[:m]
				antiseed = ('WR' * m)[:m]
		elif s_col % 2 == 0:
			seed = ('RW' * m)[:m]
			antiseed = ('WR' * m)[:m]
		else:
			seed = ('WR' * m)[:m]
			antiseed = ('RW' * m)[:m]
		fin = []
		for k in range(n):
			if k % 2 == s_row % 2:
				fin.append(seed)
			else:
				fin.append(antiseed)
		f_bool = True
		for k in range(n):
			for p in range(m):
				if l[k][p] == '.':
					continue
				elif l[k][p] != fin[k][p]:
					f_bool = False
		if f_bool:
			print('YES')
			for k in range(n):
				print(fin[k])
		else:
			print('NO')
	else:
		print('YES')
		for k in range(n):
			if k % 2 == 0:
				print(('RW' * m)[:m])
			else:
				print(('WR' * m)[:m])
t = 1
t = int(i())
for _ in range(t):
	main()


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	ans1 = []
	ans2 = []
	for i in range(n):
		if m % 2 == 0:
			row1 = 'RW' * (m // 2)
			row2 = 'WR' * (m // 2)
		else:
			row1 = 'RW' * (m // 2) + 'R'
			row2 = 'WR' * (m // 2) + 'W'
		if i % 2 == 0:
			ans1.append(row1)
			ans2.append(row2)
		else:
			ans1.append(row2)
			ans2.append(row1)
	sum1 = 0
	sum2 = 0
	count = 0
	for i in range(n):
		inp = input()
		for j in range(m):
			if inp[j] != '.':
				count += 1
				if inp[j] == ans1[i][j]:
					sum1 += 1
				else:
					sum2 += 1
			else:
				pass
	if sum1 == count:
		print('YES')
		for i in ans1:
			print(i)
	elif sum2 == count:
		print('YES')
		for i in ans2:
			print(i)
	else:
		print('NO')


from sys import stdin
for testcase in range(int(stdin.readline())):
	(n, m) = map(int, stdin.readline().split())
	matrix = [input() for row in range(n)]
	possibility1 = []
	possibility2 = []
	for row in range(n):
		possibility1row = ''
		possibility2row = ''
		for column in range(m):
			if row % 2:
				possibility1row += ['R', 'W'][column % 2]
				possibility2row += ['W', 'R'][column % 2]
			else:
				possibility1row += ['W', 'R'][column % 2]
				possibility2row += ['R', 'W'][column % 2]
		possibility1.append(possibility1row)
		possibility2.append(possibility2row)
	possibility1fittingtest = possibility2fittingtest = True
	for row in range(n):
		for column in range(m):
			if matrix[row][column] != '.':
				if possibility1fittingtest:
					possibility1fittingtest = possibility1[row][column] == matrix[row][column]
				if possibility2fittingtest:
					possibility2fittingtest = matrix[row][column] == possibility2[row][column]
	if possibility1fittingtest:
		print('YES')
		for row in possibility1:
			print(row)
	elif possibility2fittingtest:
		print('YES')
		for row in possibility2:
			print(row)
	else:
		print('NO')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	pass

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def lts(l):
	s = ''.join(map(str, l))
	return s

def stl(s):
	l = list(s)
	return l

def sq(a, target, arr=[]):
	s = sum(arr)
	if s == target:
		return arr
	if s >= target:
		return
	for i in range(len(a)):
		n = a[i]
		remaining = a[i + 1:]
		ans = sq(remaining, target, arr + [n])
		if ans:
			return ans

def SieveOfEratosthenes(n):
	cnt = 0
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, n + 1):
		if prime[p]:
			cnt += 1
	return cnt

def nCr(n, r):
	f = math.factorial
	return f(n) // f(r) // f(n - r)
mod = int(1000000000.0) + 7

def ssinp():
	return input()

def iinp():
	return int(input())

def nninp():
	return map(int, input().split())

def llinp():
	return list(map(int, input().split()))

def p(xyz):
	print(xyz)

def p2(a, b):
	print(a, b)
import math
sys.setrecursionlimit(300000)
for __ in range(iinp()):
	(n, m) = nninp()
	mat = []
	f = 0
	for i in range(n):
		s = list(ssinp())
		mat.append(s)
	for k in range(50):
		for i in range(n):
			for j in range(m):
				if mat[i][j] != '.':
					if i > 0 and mat[i - 1][j] != mat[i][j]:
						if mat[i][j] == 'R':
							mat[i - 1][j] = 'W'
						else:
							mat[i - 1][j] = 'R'
					elif i > 0 and mat[i - 1][j] == mat[i][j]:
						f = 1
					if i < n - 1 and mat[i + 1][j] != mat[i][j]:
						if mat[i][j] == 'R':
							mat[i + 1][j] = 'W'
						else:
							mat[i + 1][j] = 'R'
					elif i < n - 1 and mat[i + 1][j] == mat[i][j]:
						f = 1
					if j > 0 and mat[i][j - 1] != mat[i][j]:
						if mat[i][j] == 'R':
							mat[i][j - 1] = 'W'
						else:
							mat[i][j - 1] = 'R'
					elif j > 0 and mat[i][j - 1] == mat[i][j]:
						f = 1
					if j < m - 1 and mat[i][j + 1] != mat[i][j]:
						if mat[i][j] == 'R':
							mat[i][j + 1] = 'W'
						else:
							mat[i][j + 1] = 'R'
					elif j < m - 1 and mat[i][j + 1] == mat[i][j]:
						f = 1
	cnt1 = 0
	for i in range(n):
		for j in range(m):
			if mat[i][j] == '.':
				cnt1 += 1
	if cnt1 == n * m:
		flag = 0
		for i in range(n):
			if i > 0 and mat[i - 1][0] == 'R':
				flag = 1
			elif i > 0 and mat[i - 1][0] == 'W':
				flag = 0
			for j in range(m):
				if flag == 0:
					mat[i][j] = 'R'
					flag = 1
				else:
					mat[i][j] = 'W'
					flag = 0
		print('YES')
		for c in mat:
			print(lts(c))
	elif f == 0:
		print('YES')
		for c in mat:
			print(lts(c))
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	arr = []
	for i in range(n):
		arr += [input()]
	sol1 = []
	sol2 = []
	for i in range(n):
		cur = ''
		for j in range(m):
			if (i + j) % 2 == 0:
				cur += 'W'
			else:
				cur += 'R'
		sol1 += [cur]
	for i in range(n):
		cur = ''
		for j in range(m):
			if sol1[i][j] == 'R':
				cur += 'W'
			else:
				cur += 'R'
		sol2 += [cur]
	flag1 = 0
	flag2 = 0
	for i in range(n):
		for j in range(m):
			if arr[i][j] != '.' and arr[i][j] != sol1[i][j]:
				flag1 = 1
			if arr[i][j] != '.' and arr[i][j] != sol2[i][j]:
				flag2 = 1
	if flag1 == 0:
		print('YES')
		for x in sol1:
			print(x)
	elif flag2 == 0:
		print('YES')
		for x in sol2:
			print(x)
	else:
		print('NO')


import sys
from os import path
import bisect
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output1.txt', 'w')
from heapq import heappop, heappush, heapify
from math import ceil
maxi = sys.maxsize
mini = -maxi
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	lis = []
	for i in range(n):
		s = input()
		l = []
		for i in s:
			l.append(i)
		lis.append(l)
	f = True
	(m1, m2) = ([], [])
	(l, l1) = ([], [])
	for i in range(m):
		if i % 2:
			l1.append('R')
			l.append('W')
		else:
			l.append('R')
			l1.append('W')
	for i in range(n):
		if i % 2:
			m2.append(l)
			m1.append(l1)
		else:
			m1.append(l)
			m2.append(l1)
	i = 0
	f = True
	while i < n and f:
		j = 0
		while j < m:
			if lis[i][j] != '.' and lis[i][j] != m2[i][j]:
				f = False
				break
			j += 1
		i += 1
	if f:
		print('YES')
		for i in m2:
			print(*i, sep='')
	else:
		f = True
		i = 0
		while i < n and f:
			j = 0
			while j < m:
				if lis[i][j] != '.' and lis[i][j] != m1[i][j]:
					f = False
					break
				j += 1
			i += 1
		if f:
			print('YES')
			for i in m1:
				print(*i, sep='')
		else:
			print('NO')


import os
import sys
from io import BytesIO, IOBase
from collections import Counter
import math as mt
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def lcm(a, b):
	return a * b / gcd(a, b)
mod = int(1000000000.0) + 7

def power(k, n):
	if n == 0:
		return 1
	if n % 2:
		return power(k, n - 1) * k % mod
	t = power(k, n // 2)
	return t * t % mod

def totalPrimeFactors(n):
	count = 0
	if n % 2 == 0:
		count += 1
		while n % 2 == 0:
			n //= 2
	i = 3
	while i * i <= n:
		if n % i == 0:
			count += 1
			while n % i == 0:
				n //= i
		i += 2
	if n > 2:
		count += 1
	return count

def main():
	for _ in range(int(input())):
		(n, m) = map(int, input().split())
		a = []
		for i in range(n):
			s = input()
			t = []
			for j in s:
				if j == 'R' or j == 'W' or j == '.':
					t.append(j)
			a.append(t)
		b = [['.' for j in range(m)] for i in range(n)]
		c = [['.' for j in range(m)] for i in range(n)]
		for i in range(n):
			for j in range(m):
				if (i + j) % 2:
					b[i][j] = 'R'
					c[i][j] = 'W'
				else:
					b[i][j] = 'W'
					c[i][j] = 'R'
		f = 0
		for i in range(n):
			for j in range(m):
				if a[i][j] != '.':
					if a[i][j] != b[i][j]:
						f = 1
		if f == 0:
			print('YES')
			for i in b:
				for j in i:
					print(j, end='')
				print('')
		else:
			f = 0
			for i in range(n):
				for j in range(m):
					if a[i][j] != '.':
						if a[i][j] != c[i][j]:
							f = 1
			if f == 0:
				print('YES')
				for i in c:
					for j in i:
						print(j, end='')
					print('')
			else:
				print('NO')
	return
main()


for i in range(int(input())):
	(y, x) = map(int, input().split())
	m = [input() for i in range(y)]
	r = [''.join(('RW'[(i + j) % 2] for j in range(x))) for i in range(y)]
	w = [''.join(('WR'[(i + j) % 2] for j in range(x))) for i in range(y)]
	if all((m[i][j] == '.' or m[i][j] == r[i][j] for i in range(y) for j in range(x))):
		print('YES')
		[print(i) for i in r]
	elif all((m[i][j] == '.' or m[i][j] == w[i][j] for i in range(y) for j in range(x))):
		print('YES')
		[print(i) for i in w]
	else:
		print('NO')


for _ in range(int(input())):
	(r, c) = map(int, input().split())
	found = []
	for rows in range(r):
		row = input()
		for i in range(len(row)):
			if row[i] != '.':
				found.append([rows, i, row[i]])
	create = [['0' for cccc in range(c)] for roro in range(r)]
	visited = [[False for cc in range(c)] for roro in range(r)]
	if len(found) == 0:
		found.append([0, 0, 'R'])
	rrr = found[0][0]
	ccc = found[0][1]
	create[rrr][ccc] = found[0][2]
	Q = [[found[0][0], found[0][1], found[0][2]]]
	while Q:
		tmp = Q.pop()
		create[tmp[0]][tmp[1]] = tmp[2]
		visited[tmp[0]][tmp[1]] = 1
		val = tmp[2]
		if val == 'R':
			val = 'W'
		else:
			val = 'R'
		y = tmp[0]
		x = tmp[1]
		if y - 1 >= 0 and (not visited[y - 1][x]):
			Q.append([y - 1, x, val])
		if x + 1 < c and (not visited[y][x + 1]):
			Q.append([y, x + 1, val])
		if y + 1 < r and (not visited[y + 1][x]):
			Q.append([y + 1, x, val])
		if x - 1 >= 0 and (not visited[y][x - 1]):
			Q.append([y, x - 1, val])
	f = False
	for el in found:
		if el[2] != create[el[0]][el[1]]:
			print('NO')
			f = True
			break
	if not f:
		print('YES')
		ans = ''
		for row in create:
			for el in row:
				ans += el
			print(ans)
			ans = ''


def check(m, n, x, a):
	c = 0
	for i in range(m):
		for j in range(n):
			if c == 0 and (a[i][j] == 'R' or a[i][j] == 'W'):
				x[(i + j) % 2] = a[i][j]
				if a[i][j] != 'R':
					x[(i + j + 1) % 2] = 'R'
				else:
					x[(i + j + 1) % 2] = 'W'
				c = 1
			elif a[i][j] == 'R':
				if x.index('R') != (i + j) % 2:
					return 'No'
			elif a[i][j] == 'W':
				if x.index('W') != (i + j) % 2:
					return 'No'
	return 'Yes'
z = int(input())
for _ in range(z):
	(m, n) = map(int, input().split())
	a = []
	for i in range(m):
		s = input()
		a.append(list(s))
	x = ['.', '.']
	s = check(m, n, x, a)
	print(s)
	if x == ['.', '.']:
		x = ['R', 'W']
		for i in range(m):
			for j in range(n):
				print(x[(i + j) % 2], end='')
			print()
	elif s == 'Yes':
		for i in range(m):
			for j in range(n):
				print(x[(i + j) % 2], end='')
			print()


T = int(input())
for _ in range(T):
	(n, m) = map(int, input().split(' '))
	grid = [list(input()) for i in range(n)]
	valid = True

	def dfs(i, j, paint):
		if 0 <= i < n and 0 <= j < m:
			if grid[i][j] == '.':
				grid[i][j] = paint
				paint = 'R' if paint == 'W' else 'W'
				dfs(i + 1, j, paint)
				dfs(i - 1, j, paint)
				dfs(i, j + 1, paint)
				dfs(i, j - 1, paint)
			elif grid[i][j] == 'R' and paint == 'W' or (grid[i][j] == 'W' and paint == 'R'):
				return False
		return True
	for i in range(n):
		for j in range(m):
			if grid[i][j] == 'R':
				if True and dfs(i + 1, j, 'W') and dfs(i - 1, j, 'W') and dfs(i, j + 1, 'W') and dfs(i, j - 1, 'W'):
					pass
				else:
					valid = 0
					break
			elif grid[i][j] == 'W':
				if True and dfs(i + 1, j, 'R') and dfs(i - 1, j, 'R') and dfs(i, j + 1, 'R') and dfs(i, j - 1, 'R'):
					pass
				else:
					valid = 0
					break
	for i in range(n):
		for j in range(m):
			if grid[i][j] == '.':
				dfs(i, j, 'R')
	if valid:
		print('YES')
		for row in grid:
			print(''.join(row))
	else:
		print('NO')


import math, sys
from itertools import permutations
from collections import defaultdict, Counter, deque
from heapq import heapify, heappush, heappop
MOD = int(1000000000.0) + 7
INF = float('inf')

def solve():
	(n, m) = map(int, input().split())
	mat = []
	for i in range(n):
		mat.append(list(input()))
	tmp = list(map(list, mat))
	for start in ('R', 'W'):
		mat = list(map(list, tmp))
		if mat[0][0] == '.':
			mat[0][0] = start
		elif mat[0][0] != start:
			continue
		res = 1
		for i in range(n):
			for j in range(m):
				down = 'R' if mat[i][j] == 'W' else 'W'
				right = 'R' if mat[i][j] == 'W' else 'W'
				if j + 1 < m:
					if mat[i][j + 1] in ('.', right):
						mat[i][j + 1] = right
					else:
						res = 0
						break
				if i + 1 < n:
					if mat[i + 1][j] in ('.', down):
						mat[i + 1][j] = down
					else:
						res = 0
						break
			if not res:
				break
		if res:
			print('YES')
			for r in mat:
				print(''.join(r))
			return
	print('NO')

def main():
	ts = 1
	ts = int(input())
	for t in range(1, ts + 1):
		solve()

def input():
	return sys.stdin.readline().rstrip('\n').strip()

def print(*args, sep=' ', end='\n'):
	first = True
	for arg in args:
		if not first:
			sys.stdout.write(sep)
		sys.stdout.write(str(arg))
		first = False
	sys.stdout.write(end)
main()


from sys import stdin, stdout

def arrin():
	return list(map(int, stdin.readline().split()))

def num1in():
	return int(stdin.readline())

def num2in():
	(a, b) = map(int, stdin.readline().split())
	return (a, b)

def num3in():
	(a, b, c) = map(int, stdin.readline().split())
	return (a, b, c)

def num4in():
	(a, b, c, d) = map(int, stdin.readline().split())
	return (a, b, c, d)

def num5in():
	(a, b, c, d, e) = map(int, stdin.readline().split())
	return (a, b, c, d, e)

def printmat(mat):
	for i in mat:
		for j in i:
			print(j, end='')
		print()

def solve(mat, n, m):
	ans = [['' for x in range(m)] for x in range(n)]
	temp = 0
	for i in range(n):
		temp = temp ^ 1
		tog = temp
		for j in range(m):
			if tog == 0:
				ans[i][j] = 'R'
				tog = 1
			else:
				ans[i][j] = 'W'
				tog = 0
	flag = 0
	for i in range(n):
		for j in range(m):
			if mat[i][j] == ans[i][j] or mat[i][j] == '.':
				continue
			else:
				flag = 1
				break
		if flag == 1:
			break
	if flag == 0:
		print('YES')
		printmat(ans)
		return
	temp = 1
	for i in range(n):
		temp = temp ^ 1
		tog = temp
		for j in range(m):
			if tog == 0:
				ans[i][j] = 'R'
				tog = 1
			else:
				ans[i][j] = 'W'
				tog = 0
	flag = 0
	for i in range(n):
		for j in range(m):
			if mat[i][j] == ans[i][j] or mat[i][j] == '.':
				continue
			else:
				flag = 1
				break
		if flag == 1:
			break
	if flag == 0:
		print('YES')
		printmat(ans)
		return
	print('NO')
	return
t = num1in()
for test in range(t):
	(n, m) = num2in()
	mat = []
	for i in range(n):
		s = input()
		mat.append(s)
	solve(mat, n, m)


import bisect
from math import *
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	mat = []
	for i in range(n):
		row = input()
		mat.append(row)
	m1 = []
	for i in range(n):
		row = ''
		for j in range(m):
			if j & 1:
				if i & 1:
					row += 'W'
				else:
					row += 'R'
			elif i & 1:
				row += 'R'
			else:
				row += 'W'
		m1.append(row)
	m2 = []
	for i in range(n):
		row = ''
		for j in range(m):
			if j & 1:
				if i & 1:
					row += 'R'
				else:
					row += 'W'
			elif i & 1:
				row += 'W'
			else:
				row += 'R'
		m2.append(row)
	flagR = False
	flagW = False
	for i in range(n):
		for j in range(m):
			if mat[i][j] != '.':
				if mat[i][j] == m1[i][j]:
					flagR = True
				elif mat[i][j] == m2[i][j]:
					flagW = True
		if flagR and flagW:
			break
	if flagW and flagR:
		print('NO')
	else:
		print('YES')
		if flagR and (not flagW):
			for i in m1:
				print(i)
		elif flagW and (not flagR):
			for i in m2:
				print(i)
		else:
			for i in m1:
				print(i)


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	ss = ['', '']
	for i in range(m):
		if i % 2 == 0:
			ss[0] += 'R'
			ss[1] += 'W'
		else:
			ss[0] += 'W'
			ss[1] += 'R'
	fl1 = True
	fl2 = True
	ans = ''
	for j in range(n):
		s = input()
		for i in range(m):
			if s[i] != '.':
				if fl1 and ss[j % 2][i] != s[i]:
					fl1 = False
				if fl2 and ss[1 - j % 2][i] != s[i]:
					fl2 = False
	if fl1:
		print('YES')
		for j in range(n):
			print(ss[j % 2])
	elif fl2:
		print('YES')
		for j in range(n):
			print(ss[1 - j % 2])
	else:
		print('NO')


t = int(input())
for you in range(t):
	l = input().split()
	n = int(l[0])
	m = int(l[1])
	s = []
	for i in range(n):
		x = input()
		s.append(x)
	poss = 1
	for i in range(n):
		for j in range(m):
			if s[i][j] == 'W':
				if (i + j) % 2:
					poss = 0
					break
			if s[i][j] == 'R':
				if (i + j) % 2 == 0:
					poss = 0
					break
		if poss == 0:
			break
	if poss:
		print('YES')
		for i in range(n):
			for j in range(m):
				if (i + j) % 2:
					print('R', end='')
				else:
					print('W', end='')
			print()
		continue
	poss = 1
	for i in range(n):
		for j in range(m):
			if s[i][j] == 'R':
				if (i + j) % 2:
					poss = 0
					break
			if s[i][j] == 'W':
				if (i + j) % 2 == 0:
					poss = 0
					break
		if poss == 0:
			break
	if poss:
		print('YES')
		for i in range(n):
			for j in range(m):
				if (i + j) % 2:
					print('W', end='')
				else:
					print('R', end='')
			print()
		continue
	print('NO')


from collections import Counter, deque
from itertools import accumulate, product, groupby
import operator
import math
from functools import reduce

def solve():
	(n, m) = [int(char) for char in input().split()]
	grid = []
	for r in range(n):
		row = [char for char in input()]
		grid.append(row)
	method_1 = False
	method_2 = False
	for (r, c) in product(range(n), range(m)):
		char = grid[r][c]
		if char == '.':
			continue
		if (r + c) % 2 == 0:
			if char == 'W':
				method_1 = True
			else:
				method_2 = True
		elif char == 'W':
			method_2 = True
		else:
			method_1 = True
	if method_1 and method_2:
		print('NO')
		return
	print('YES')
	if method_1:
		for x in range(n):
			line = ''
			for y in range(m):
				line += 'W' if (x + y) % 2 == 0 else 'R'
			print(line)
	else:
		for x in range(n):
			line = ''
			for y in range(m):
				line += 'R' if (x + y) % 2 == 0 else 'W'
			print(line)
for _ in range(int(input())):
	solve()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = [''.join(['RW'[i + j & 1] for i in range(m)]) for j in range(n)]
	b = [''.join(['WR'[i + j & 1] for i in range(m)]) for j in range(n)]
	s = list()
	for i in range(n):
		s.append(input())
	if all((s[i][j] == a[i][j] or s[i][j] == '.' for j in range(m) for i in range(n))):
		print('YES')
		print('\n'.join(a))
	elif all((s[i][j] == b[i][j] or s[i][j] == '.' for j in range(m) for i in range(n))):
		print('YES')
		print('\n'.join(b))
	else:
		print('NO')


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from collections import Counter
from collections import defaultdict as dd
flush = lambda : stdout.flush()
stdstr = lambda : stdin.readline()
stdint = lambda : int(stdin.readline())
stdpr = lambda x: stdout.write(str(x))
stdmap = lambda : map(int, stdstr().split())
stdarr = lambda : list(map(int, stdstr().split()))
mod = 1000000007
for _ in range(stdint()):
	(n, m) = stdmap()
	matrix = []
	for i in range(n):
		s = list(input())
		matrix.append(s)
	res1 = [matrix[i].copy() for i in range(n)]
	res2 = [matrix[i].copy() for i in range(n)]
	for i in range(n):
		for j in range(m):
			if (i + j) % 2 == 0:
				res1[i][j] = 'R'
				res2[i][j] = 'W'
			else:
				res1[i][j] = 'W'
				res2[i][j] = 'R'
	pos1 = True
	for i in range(n):
		for j in range(m):
			if matrix[i][j] != '.' and matrix[i][j] != res1[i][j]:
				pos1 = False
				break
		if not pos1:
			break
	if pos1:
		print('YES')
		for i in range(n):
			print(''.join(res1[i]))
		continue
	pos2 = True
	for i in range(n):
		for j in range(m):
			if matrix[i][j] != '.' and matrix[i][j] != res2[i][j]:
				pos2 = False
				break
		if not pos2:
			break
	if pos2:
		print('YES')
		for i in range(n):
			print(''.join(res2[i]))
		continue
	print('NO')


import sys, os.path
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
for t in range(int(input())):
	(n, m) = list(map(int, input().split()))
	li = []
	for i in range(n):
		l = input()
		l = list(l)
		li.append(l)
	(xm, ym) = (9999999, 9999999)
	for i in range(n):
		for j in range(m):
			if not li[i][j] == '.':
				(xm, ym) = (i, j)
				break
		if xm < 9999999 or ym < 9999999:
			break
	if xm == 9999999 and ym == 9999999:
		li[0][0] = 'R'
		(xm, ym) = (0, 0)
	pos = 1
	val = (xm + ym) % 2
	for i in range(n):
		for j in range(m):
			if (i + j) % 2 == val % 2:
				if li[i][j] == '.':
					li[i][j] = li[xm][ym]
				elif not li[i][j] == li[xm][ym]:
					pos = 0
					break
			elif li[xm][ym] == 'R':
				if li[i][j] == '.':
					li[i][j] = 'W'
				elif li[i][j] == 'R':
					pos = 0
					break
			elif li[i][j] == '.':
				li[i][j] = 'R'
			elif li[i][j] == 'W':
				pos = 0
				break
		if pos == 0:
			break
	if pos == 0:
		print('NO')
	else:
		print('YES')
		for i in li:
			print(''.join(i))


for j in range(int(input())):
	(n, m) = map(int, input().split())
	a = [input() for i in range(n)]
	d = {}
	for i in range(n):
		for j in range(m):
			if a[i][j] == '.':
				continue
			if a[i][j] not in d:
				d[a[i][j]] = [[i, j]]
			else:
				d[a[i][j]] += [[i, j]]
	l = []
	for i in range(n):
		if i & 1:
			prev = 'W'
		else:
			prev = 'R'
		temp = []
		for j in range(m):
			temp += [prev]
			if prev == 'R':
				prev = 'W'
			else:
				prev = 'R'
		l += [temp]
	arr = []
	for i in range(n):
		if i & 1:
			prev = 'R'
		else:
			prev = 'W'
		temp = []
		for j in range(m):
			temp += [prev]
			if prev == 'R':
				prev = 'W'
			else:
				prev = 'R'
		arr += [temp]
	c = 0
	if len(d) == 0:
		print('YES')
		for i in range(n):
			print(*l[i], sep='')
	else:
		for i in d:
			z = d[i]
			for j in range(len(z)):
				k = list(d[i][j])
				if l[k[0]][k[1]] != i:
					c = 1
					break
			if c == 1:
				break
		if c == 0:
			print('YES')
			for i in range(n):
				print(*l[i], sep='')
		elif c == 1:
			w = 0
			for i in d:
				z = d[i]
				for j in range(len(z)):
					k = list(d[i][j])
					if arr[k[0]][k[1]] != i:
						w = 1
						break
				if w == 1:
					break
			if w == 0:
				print('YES')
				for i in range(n):
					print(*arr[i], sep='')
			else:
				print('NO')


import sys
input = sys.stdin.readline
mii = lambda : map(int, input().split())
for _ in range(int(input())):
	(n, m) = mii()
	r = [0, 0]
	w = [0, 0]
	for i in range(n):
		s = input().strip()
		for j in range(m):
			if s[j] == 'R':
				r[i + j & 1] = 1
			if s[j] == 'W':
				w[i + j & 1] = 1
	if r[0] == 0 and w[1] == 0:
		print('YES')
		for i in range(n):
			print(''.join(map(lambda x: 'WR'[x % 2], range(i, i + m))))
	elif r[1] == 0 and w[0] == 0:
		print('YES')
		for i in range(n):
			print(''.join(map(lambda x: 'RW'[x % 2], range(i, i + m))))
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	g = []
	for i in range(n):
		g.append(input())
	mat1 = []
	mat2 = []
	flag = True
	for i in range(n):
		s1 = ''
		s2 = ''
		if flag:
			s1 += 'R'
			s2 += 'W'
		else:
			s1 += 'W'
			s2 += 'R'
		for j in range(1, m):
			if s1[j - 1] == 'W':
				s1 += 'R'
				s2 += 'W'
			else:
				s1 += 'W'
				s2 += 'R'
		mat1.append(s1)
		mat2.append(s2)
		flag = not flag
	f1 = True
	f2 = True
	for i in range(n):
		for j in range(m):
			if g[i][j] == '.':
				continue
			else:
				if g[i][j] != mat1[i][j]:
					f1 = False
				if g[i][j] != mat2[i][j]:
					f2 = False
	if f1:
		print('YES')
		for i in mat1:
			print(i)
	elif f2:
		print('YES')
		for i in mat2:
			print(i)
	else:
		print('NO')


def valid(r, c, rr, cc):
	return 0 <= rr < r and 0 <= cc < c
movX = [-1, 0, 1, 0]
movY = [0, -1, 0, 1]
for _ in range(int(input())):
	q = []
	(r, c) = map(int, input().split())
	li = []
	for i in range(r):
		li.append(list(input()))
	fail = 0
	for rr in range(r):
		for cc in range(c):
			if li[rr][cc] == 'R':
				q.append((rr, cc))
			elif li[rr][cc] == 'W':
				q.append((rr, cc))
	if not q:
		li[0][0] = 'R'
		q.append((0, 0))
	while q:
		(x, y) = q.pop(0)
		if li[x][y] == 'R':
			for i in range(4):
				xx = x + movX[i]
				yy = y + movY[i]
				if valid(r, c, xx, yy):
					if li[xx][yy] == 'R':
						fail = 1
						break
					elif li[xx][yy] == 'W':
						continue
					li[xx][yy] = 'W'
					q.append((xx, yy))
		else:
			for i in range(4):
				xx = x + movX[i]
				yy = y + movY[i]
				if valid(r, c, xx, yy):
					if li[xx][yy] == 'W':
						fail = 1
						break
					elif li[xx][yy] == 'R':
						continue
					li[xx][yy] = 'R'
					q.append((xx, yy))
		if fail:
			break
	if not fail:
		print('YES')
		for i in range(r):
			for j in range(c):
				print(li[i][j], end='')
			print('')
	else:
		print('NO')


def solve():
	(n, m) = (int(x) for x in input().split())
	field = [list(input()) for _ in range(n)]
	all_rw = True
	all_wr = True
	for i in range(n):
		for j in range(m):
			if (i + j) % 2 == 0 and field[i][j] == 'R':
				all_wr = False
			if (i + j) % 2 == 1 and field[i][j] == 'W':
				all_wr = False
			if (i + j) % 2 == 1 and field[i][j] == 'R':
				all_rw = False
			if (i + j) % 2 == 0 and field[i][j] == 'W':
				all_rw = False
	precalc = 'RW' * m
	if all_rw:
		print('YES')
		for i in range(n):
			if i % 2 == 0:
				print(precalc[:m])
			else:
				print(precalc[1:m + 1])
		return
	if all_wr:
		print('YES')
		for i in range(n):
			if i % 2 == 1:
				print(precalc[:m])
			else:
				print(precalc[1:m + 1])
		return
	print('NO')
t = int(input())
for _ in range(t):
	solve()


from os import path
from io import BytesIO, IOBase
import sys
from heapq import heappush, heappop
from functools import cmp_to_key as ctk
from collections import deque, Counter, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input().rstrip()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def bo(i):
	return ord(i) - ord('0')
file = 1

def ceil(a, b):
	return (a + b - 1) // b

def solve():
	for _ in range(1, ii() + 1):
		(n, m) = mi()
		a = []
		for i in range(n):
			a.append(si())
		ok = True
		for i in range(n):
			for j in range(m):
				if i + j & 1:
					if a[i][j] == 'W' or a[i][j] == '.':
						pass
					else:
						ok = False
						break
				elif a[i][j] == 'R' or a[i][j] == '.':
					pass
				else:
					ok = False
					break
		if ok:
			print('YES')
			for i in range(n):
				for j in range(m):
					if i + j & 1:
						print('W', end='')
					else:
						print('R', end='')
				print()
			continue
		ok = True
		for i in range(n):
			for j in range(m):
				if i + j & 1:
					if a[i][j] == 'R' or a[i][j] == '.':
						pass
					else:
						ok = False
						break
				elif a[i][j] == 'W' or a[i][j] == '.':
					pass
				else:
					ok = False
					break
		if ok:
			print('YES')
			for i in range(n):
				for j in range(m):
					if i + j & 1:
						print('R', end='')
					else:
						print('W', end='')
				print()
		else:
			print('NO')
if file:
	if path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	else:
		input = sys.stdin.readline
solve()


t = int(input())
for i in range(t):
	q = input().split()
	n = int(q[0])
	m = int(q[1])
	a = []
	for j in range(n):
		w = input()
		l = []
		for ch in w:
			l.append(ch)
		a.append(l)
	check = 0
	for j in range(n):
		for k in range(m):
			if (j + k) % 2 == 0:
				if a[j][k] == 'W':
					check = 1
			elif a[j][k] == 'R':
				check = 1
	if check == 0:
		print('YES')
		for j in range(n):
			for k in range(m):
				if (j + k) % 2 == 0:
					print('R', end='')
				else:
					print('W', end='')
			print('')
	else:
		check = 0
		for j in range(n):
			for k in range(m):
				if (j + k) % 2 == 0:
					if a[j][k] == 'R':
						check = 1
				elif a[j][k] == 'W':
					check = 1
		if check == 0:
			print('YES')
			for j in range(n):
				for k in range(m):
					if (j + k) % 2 == 0:
						print('W', end='')
					else:
						print('R', end='')
				print('')
		else:
			print('NO')


def foo(arr, n, m):
	(i, j, color) = (-1, -1, None)
	tmp = ['W', 'R']
	for i1 in range(n):
		for j1 in range(m):
			if arr[i1][j1] in ['W', 'R']:
				(i, j, color) = (i1, j1, tmp.index(arr[i1][j1]))
				break
		if color != None:
			break
	if color != None:
		odd = True
		if (i + j) % 2 == 0:
			odd = False
		if odd:
			for i1 in range(n):
				for j1 in range(m):
					if (i1 + j1) % 2 != 0:
						if arr[i1][j1] == '.':
							arr[i1][j1] = tmp[color]
						elif arr[i1][j1] != tmp[color]:
							print('NO')
							return
					elif arr[i1][j1] == '.':
						arr[i1][j1] = tmp[color - 1]
					elif arr[i1][j1] != tmp[color - 1]:
						print('NO')
						return
			print('YES')
			print('\n'.join([''.join([item for item in row]) for row in arr]))
			return
		else:
			for i1 in range(n):
				for j1 in range(m):
					if (i1 + j1) % 2 == 0:
						if arr[i1][j1] == '.':
							arr[i1][j1] = tmp[color]
						elif arr[i1][j1] != tmp[color]:
							print('NO')
							return
					elif arr[i1][j1] == '.':
						arr[i1][j1] = tmp[color - 1]
					elif arr[i1][j1] != tmp[color - 1]:
						print('NO')
						return
			print('YES')
			print('\n'.join([''.join([item for item in row]) for row in arr]))
			return
	else:
		for i1 in range(n):
			for j1 in range(m):
				if (i1 + j1) % 2 == 0:
					arr[i1][j1] = tmp[1]
				else:
					arr[i1][j1] = tmp[0]
		print('YES')
		print('\n'.join([''.join([item for item in row]) for row in arr]))
		return

def main():
	t = int(input())
	for i in range(t):
		(n, m) = map(int, input().split())
		arr = []
		for j in range(n):
			arr.append([k for k in input()])
		foo(arr, n, m)
main()


import sys, os.path
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r+')
	sys.stdout = open('output.txt', 'w')
sys.setrecursionlimit(200000)
mod = 10 ** 9 + 7
from collections import defaultdict

def solve(a, p):
	for i in range(n):
		for j in range(m):
			if a[i][j] == 'R':
				prev = -1
				for k in range(j - 1, -1, -1):
					if a[i][k] == '.':
						a[i][k] = p[prev]
						prev = -1 * prev
					else:
						if a[i][k] != p[prev]:
							return 'NO'
						prev = -1 * prev
				prev = -1
				for k in range(j + 1, m):
					if a[i][k] == '.':
						a[i][k] = p[prev]
						prev = -1 * prev
					else:
						if a[i][k] != p[prev]:
							return 'NO'
						prev = -1 * prev
				prev = -1
				for k in range(i - 1, -1, -1):
					if a[k][j] == '.':
						a[k][j] = p[prev]
						prev = -1 * prev
					else:
						if a[k][j] != p[prev]:
							return 'NO'
						prev = -1 * prev
				prev = -1
				for k in range(i + 1, n):
					if a[k][j] == '.':
						a[k][j] = p[prev]
						prev = -1 * prev
					else:
						if a[k][j] != p[prev]:
							return 'NO'
						prev = -1 * prev
			if a[i][j] == 'W':
				prev = 1
				for k in range(j - 1, -1, -1):
					if a[i][k] == '.':
						a[i][k] = p[prev]
						prev = -1 * prev
					else:
						if a[i][k] != p[prev]:
							return 'NO'
						prev = -1 * prev
				prev = 1
				for k in range(j + 1, m):
					if a[i][k] == '.':
						a[i][k] = p[prev]
						prev = -1 * prev
					else:
						if a[i][k] != p[prev]:
							return 'NO'
						prev = -1 * prev
				prev = 1
				for k in range(i - 1, -1, -1):
					if a[k][j] == '.':
						a[k][j] = p[prev]
						prev = -1 * prev
					else:
						if a[k][j] != p[prev]:
							return 'NO'
						prev = -1 * prev
				prev = 1
				for k in range(i + 1, n):
					if a[k][j] == '.':
						a[k][j] = p[prev]
						prev = -1 * prev
					else:
						if a[k][j] != p[prev]:
							return 'NO'
						prev = -1 * prev
	return 'YES'
for _ in range(int(input())):
	p = [0, 'R', 'W']
	a = []
	(n, m) = map(int, input().split())
	for i in range(n):
		a.append(list(input()))
	flag = 0
	index = -1
	for i in range(n):
		for j in range(m):
			if a[i][j] == 'R' or a[i][j] == 'W':
				x = i
				y = j
				flag = 1
				break
	ans = [''] * n
	ans1 = [''] * n
	for i in range(n):
		if m < 2:
			if i % 2:
				ans[i] = 'R'
			else:
				ans[i] = 'W'
		elif i % 2:
			ans[i] = 'RW' * (m // 2) + 'R' * (m % 2)
		else:
			ans[i] = 'WR' * (m // 2) + 'W' * (m % 2)
	for i in range(n):
		if m < 2:
			if i % 2:
				ans1[i] = 'W'
			else:
				ans1[i] = 'R'
		elif i % 2 == 0:
			ans1[i] = 'RW' * (m // 2) + 'R' * (m % 2)
		else:
			ans1[i] = 'WR' * (m // 2) + 'W' * (m % 2)
	if flag:
		for i in range(n):
			if flag == 2:
				break
			for j in range(m):
				if a[i][j] == ans[i][j] or a[i][j] == '.':
					continue
				else:
					flag = 2
					break
		if flag == 1:
			print('YES')
			for i in ans:
				print(''.join(i))
		else:
			flag = 1
			for i in range(n):
				if flag == 2:
					break
				for j in range(m):
					if a[i][j] == ans1[i][j] or a[i][j] == '.':
						continue
					else:
						flag = 2
						break
			if flag == 1:
				print('YES')
				for i in ans1:
					print(''.join(i))
			else:
				print('NO')
	else:
		print('YES')
		for i in ans:
			print(''.join(i))


def solve(mx, n, m, first):
	for i in range(n):
		for j in range(m):
			if i == 0 and j == 0:
				if mx[i + 1][j] != first and mx[i][j + 1] != first:
					mx[i][j] = first
					prev = first
					if first == 'W':
						new = 'R'
					else:
						new = 'W'
				else:
					return False
			elif j == 0:
				prev = mx[i - 1][j]
				if prev == 'W':
					new = 'R'
					prev = 'R'
				else:
					new = 'W'
					prev = 'R'
				if mx[i + 1][j] != new and mx[i][j + 1] != new:
					mx[i][j] = new
				else:
					return False
			else:
				prev = mx[i][j - 1]
				if prev == 'W':
					new = 'R'
				else:
					new = 'W'
				if mx[i + 1][j] != new and mx[i][j + 1] != new:
					mx[i][j] = new
				else:
					return False
	return True

def show(mx):
	for i in range(len(mx) - 1):
		print(''.join(mx[i][:-1]))
for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	mx1 = []
	found = False
	for i in range(n):
		t = input()
		tt = []
		for j in range(m):
			tt.append(t[j])
		tt.append('-')
		mx1.append(tt)
	mx1.append(['-' for i in range(m + 1)])
	mx2 = []
	for i in range(n + 1):
		t = []
		for j in range(m + 1):
			t.append(mx1[i][j])
		mx2.append(t)
	if mx1[0][0] == '.':
		ans1 = solve(mx1, n, m, 'W')
		if ans1:
			print('YES')
			show(mx1)
		else:
			ans2 = solve(mx2, n, m, 'R')
			if ans2:
				print('YES')
				show(mx2)
			else:
				print('NO')
	else:
		ans = solve(mx1, n, m, mx1[0][0])
		if ans:
			print('YES')
			show(mx1)
		else:
			print('NO')


import collections
import itertools
from typing import Collection
(red, white) = 'RW'

def invert_color(color):
	if color == red:
		return white
	return red

def gen(first_color=red):
	second_color = white if first_color == red else red
	colors = [first_color, second_color]
	while True:
		yield from colors

def reconstruct_grid(n, m, first_color):
	grid = []
	for _ in range(n):
		line = list(itertools.islice(gen(first_color=first_color), m))
		grid.append(line)
		first_color = invert_color(first_color)
	return grid

def print_grid(grid):
	for line in grid:
		print(''.join(line))

def validate(grid, reconstructed_grid):
	(n, m) = (len(grid), len(grid[0]))
	if reconstructed_grid is None:
		reconstructed_grid = reconstruct_grid(n, m, red)
		print('YES')
		print_grid(reconstructed_grid)
		return
	for i in range(n):
		for j in range(m):
			if grid[i][j] not in [red, white]:
				continue
			if grid[i][j] != reconstructed_grid[i][j]:
				print('NO')
				return
	print('YES')
	print_grid(reconstructed_grid)

def solve():
	(n, m) = [int(x) for x in input().split()]
	(grid, reconstructed_grid) = ([], None)
	for _ in range(n):
		grid.append(list(input()))
	for line in range(n):
		non_empty = [index for index in range(m) if grid[line][index] in [red, white]]
		if len(non_empty) == 0:
			continue
		first_pos = non_empty[0]
		color = grid[line][first_pos]
		first_pos = first_pos % 2
		if first_pos & 1:
			color = invert_color(color)
		if line & 1:
			color = invert_color(color)
		reconstructed_grid = reconstruct_grid(n, m, color)
		break
	validate(grid, reconstructed_grid)
for _ in range(int(input().strip())):
	solve()


int_inp = lambda : int(input())
strng = lambda : input().strip()
strl = lambda : list(input().strip())
mul = lambda : map(int, input().split())
mulf = lambda : map(float, input().split())
seq = lambda : list(map(int, input().split()))
import math
from collections import Counter, defaultdict
for _ in range(int_inp()):
	(a, b) = mul()
	p = 0
	k = ['R', 'W'] * (b // 2 + 1)
	k = k[:b]
	L = ['W', 'R'] * (b // 2 + 1)
	L = L[:b]
	a1 = [k, L] * (a // 2 + 1)
	a1 = a1[:a]
	a2 = [L, k] * (a // 2 + 1)
	a2 = a2[:a]
	c = []
	d = ''
	for i in range(a):
		c1 = input()
		d = d + c1
		c.append(list(c1))
	if d.find('R') == -1:
		w = d.find('W')
	elif d.find('W') == -1:
		w = d.find('R')
	else:
		w = min(d.find('W'), d.find('R'))
	if d[w] == a1[w // b][w % b]:
		for i in range(a):
			for j in range(b):
				if c[i][j] == '.':
					continue
				elif c[i][j] == a1[i][j]:
					continue
				else:
					print('no')
					p = 1
					break
			if p == 1:
				break
		if p == 0:
			print('yes')
			for i in range(a):
				print(''.join(a1[i]))
	else:
		for i in range(a):
			for j in range(b):
				if c[i][j] == '.':
					continue
				elif c[i][j] == a2[i][j]:
					continue
				else:
					print('no')
					p = 1
					break
			if p == 1:
				break
		if p == 0:
			print('yes')
			for i in range(a):
				print(''.join(a2[i]))


part = {'R': 'W', 'W': 'R'}

def show(M):
	for li in M:
		print(*li)
	print()

def make(n, m, c):
	M = [[None] * m for i in range(n)]
	for i in range(n):
		for j in range(m):
			if (i + j) % 2:
				M[i][j] = part[c]
			else:
				M[i][j] = c
	return M

def check(A, B, n, m):
	for i in range(n):
		for j in range(m):
			if A[i][j] != B[i][j] and B[i][j] != '.':
				return False
	return True

def solve(Arr, n, m):
	for char in ['R', 'W']:
		M = make(n, m, char)
		if check(M, Arr, n, m):
			print('YES')
			for li in M:
				print(''.join(li))
			return
	print('NO')
for case in range(int(input())):
	(n, m) = map(int, input().split())
	Arr = []
	for i in range(n):
		li = list(input())
		Arr.append(li)
	solve(Arr, n, m)


t = int(input())
for inh in range(0, t):
	(n, m) = map(int, input().split())
	a = []
	(x, y) = (True, True)
	for i in range(0, n):
		s = input()
		if x:
			if i % 2 == 0:
				st = 'R'
				se = 'W'
			else:
				st = 'W'
				se = 'R'
			for j in range(0, m):
				if j % 2 == 0:
					if s[j] == se:
						x = False
						break
				elif s[j] == st:
					x = False
					break
		if y:
			if i % 2 == 0:
				st = 'W'
				se = 'R'
			else:
				st = 'R'
				se = 'W'
			for j in range(0, m):
				if j % 2 == 0:
					if s[j] == se:
						y = False
						break
				elif s[j] == st:
					y = False
					break
	if x or y:
		if x:
			a = 'R'
			b = 'W'
		else:
			a = 'W'
			b = 'R'
		print('YES')
		for i in range(0, n):
			if i % 2 == 0:
				st = a
				se = b
			else:
				st = b
				se = a
			for j in range(0, m):
				if j % 2 == 0:
					print(st, end='')
				else:
					print(se, end='')
			print('')
	else:
		print('NO')


test_case_num = int(input())
RED_EVEN = 'RW' * 1000
RED_ODD = 'WR' * 1000
for _ in range(test_case_num):
	inp = input().split()
	n = int(inp[0])
	m = int(inp[1])
	Red_even = True
	Red_odd = True
	for i in range(n):
		line = input()
		line_pos = i % 2 == 0
		for j in range(m):
			if line[j] == 'R':
				if j % 2 == 0:
					if line_pos:
						Red_odd = False
					else:
						Red_even = False
				elif line_pos:
					Red_even = False
				else:
					Red_odd = False
			elif line[j] == 'W':
				if j % 2 == 0:
					if line_pos:
						Red_even = False
					else:
						Red_odd = False
				elif line_pos:
					Red_odd = False
				else:
					Red_even = False
	if Red_even:
		print('YES')
		for i in range(n):
			if i % 2 == 0:
				print(RED_EVEN[:m])
			else:
				print(RED_ODD[:m])
	elif Red_odd:
		print('YES')
		for i in range(n):
			if i % 2 == 0:
				print(RED_ODD[:m])
			else:
				print(RED_EVEN[:m])
	else:
		print('NO')


import io
import os
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from heapq import heappush, heappop, heapify
from math import gcd, inf

def solve(R, C, grid):
	color = {}
	for r in range(R):
		for c in range(C):
			if grid[r][c] != '.':
				if (r + c) % 2 in color and color[(r + c) % 2] != grid[r][c]:
					return 'NO'
				color[(r + c) % 2] = grid[r][c]
	if not color:
		color[0] = 'R'
		color[1] = 'W'
	if 0 not in color:
		if color[1] == 'R':
			color[0] = 'W'
		else:
			color[0] = 'R'
	if 1 not in color:
		if color[0] == 'R':
			color[1] = 'W'
		else:
			color[1] = 'R'
	if color[0] == color[1]:
		return 'NO'
	for r in range(R):
		for c in range(C):
			grid[r][c] = color[(r + c) % 2]
	return 'YES\n' + '\n'.join((''.join(row) for row in grid))
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
TC = int(input())
for tc in range(1, TC + 1):
	(N, M) = [int(x) for x in input().split()]
	grid = [list(input().decode().rstrip()) for i in range(N)]
	ans = solve(N, M, grid)
	print(ans)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	g = [input() for _ in range(n)]
	a = [('RW' * m)[:m], ('WR' * m)[:m]]

	def chk():
		for i in range(n):
			for j in range(m):
				if g[i][j] != '.' and g[i][j] != a[i % 2][j]:
					return False
		return True
	if chk():
		print('YES')
		for i in range(n):
			print(a[i % 2])
	else:
		(a[0], a[1]) = (a[1], a[0])
		if chk():
			print('YES')
			for i in range(n):
				print(a[i % 2])
		else:
			print('NO')


from collections import deque, defaultdict
NONE = 0
RED = 1
WHITE = 2

def solve(n, m):

	def getColor(x):
		if x == 'R':
			return RED
		elif x == 'W':
			return WHITE
		return None
	colors = set()
	for i in range(n):
		s = input()
		for (j, x) in enumerate(s):
			num = (i + j) % 2
			color = getColor(x)
			if color is None:
				continue
			if num == 1:
				color = 3 - color
			colors.add(color)
	if len(colors) == 2:
		return (None, n, m)
	elif len(colors) == 1:
		return (colors.pop(), n, m)
	return (RED, n, m)

def printResult(color, n, m):
	if color is None:
		print('NO')
		return
	print('YES')

	def getLetter(k, color):
		if (k + color) % 2 == 0:
			return 'W'
		return 'R'
	for i in range(n):
		s = ''.join([getLetter(i + j, color) for j in range(m)])
		print(s)
t = int(input())
results = deque()
for _ in range(t):
	(n, m) = list(map(int, input().split(' ')))
	result = solve(n, m)
	results.append(result)
for result in results:
	printResult(*result)


for _ in range(0, int(input())):
	(n, m) = map(int, input().split())
	sr = 0
	f = False
	for r in range(0, n):
		for (i, x) in enumerate(input()):
			if x == 'W' and i % 2 == r % 2 or (x == 'R' and i % 2 != r % 2):
				f = True
				if sr == 0 or sr == 1:
					sr = 1
				else:
					sr = -1
			if x == 'R' and i % 2 == r % 2 or (x == 'W' and i % 2 != r % 2):
				f = True
				if sr == 0 or sr == 2:
					sr = 2
				else:
					sr = -1
	if sr == -1:
		print('NO')
	else:
		print('YES')
		w = sr % 2
		for i in range(0, n):
			if i % 2 == w:
				print(('RW' * m)[:m])
			else:
				print(('WR' * m)[:m])


import math
k = int(input())
for i in range(k):
	(hang, heng) = map(int, input().split())
	list1 = []
	list2 = []
	listw = []
	listr = []
	for i in range(hang):
		s = input()
		for j in range(heng):
			if s[j] == 'W':
				listw.append((i, j))
			if s[j] == 'R':
				listr.append((i, j))
	for i in range(hang):
		if i % 2 == 0:
			for j in range(heng):
				if j % 2 == 0:
					list1.append((i, j))
				else:
					list2.append((i, j))
		else:
			for j in range(heng):
				if j % 2 == 0:
					list2.append((i, j))
				else:
					list1.append((i, j))
	if set(listw) <= set(list1) and set(listr) <= set(list2):
		print('YES')
		ans = []
		for i in range(hang):
			ans.append([0] * heng)
		for i in list1:
			ans[i[0]][i[1]] = 'W'
		for i in list2:
			ans[i[0]][i[1]] = 'R'
		for i in range(len(ans)):
			print(''.join(ans[i]))
	elif set(listr) <= set(list1) and set(listw) <= set(list2):
		print('YES')
		ans = []
		for i in range(hang):
			ans.append([0] * heng)
		for i in list1:
			ans[i[0]][i[1]] = 'R'
		for i in list2:
			ans[i[0]][i[1]] = 'W'
		for i in range(len(ans)):
			print(''.join(ans[i]))
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	flag = []
	for i in range(n):
		flag.append(input())
	white = False
	done = False
	valid = True
	for i in range(n):
		for j in range(m):
			if flag[i][j] == '.':
				continue
			c1 = flag[i][j] == 'W' and (i + j) % 2 == 0
			c2 = flag[i][j] == 'R' and (i + j) % 2 == 1
			if not done:
				white = c1 or c2
				done = True
			else:
				d1 = white and (c1 or c2)
				d2 = not white and (not c1 and (not c2))
				if not d1 and (not d2):
					valid = False
					break
		if not valid:
			break
	if not valid:
		print('NO')
		continue
	res = [[None] * m for _ in range(n)]
	for i in range(n):
		for j in range(m):
			res[i][j] = 'RW'[(i + j) % 2 ^ white]
	print('YES')
	for row in res:
		print(''.join(row))


import sys
sys.setrecursionlimit(10 ** 9)

def gg(s, i, j, n, m):
	if s[i][j] == 'R':
		x = 'W'
	else:
		x = 'R'
	if i - 1 >= 0 and s[i - 1][j] == '.':
		s[i - 1][j] = x
		gg(s, i - 1, j, n, m)
	if i + 1 < n and s[i + 1][j] == '.':
		s[i + 1][j] = x
		gg(s, i + 1, j, n, m)
	if j + 1 < m and s[i][j + 1] == '.':
		s[i][j + 1] = x
		gg(s, i, j + 1, n, m)
	if j - 1 >= 0 and s[i][j - 1] == '.':
		s[i][j - 1] = x
		gg(s, i, j - 1, n, m)
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = []
	for i in range(n):
		s.append(list(input()))
	q = 0
	for i in range(n):
		q += s[i].count('.')
	if q == n * m:
		s[0][0] = 'R'
		gg(s, 0, 0, n, m)
	else:
		for i in range(n):
			for j in range(m):
				if s[i][j] != '.':
					gg(s, i, j, n, m)
	x = 0
	for i in range(n):
		for j in range(m):
			if i + 1 < n and s[i + 1][j] == s[i][j]:
				x = -1
				break
			if i - 1 >= 0 and s[i - 1][j] == s[i][j]:
				x = -1
				break
			if j - 1 >= 0 and s[i][j - 1] == s[i][j]:
				x = -1
				break
			if j + 1 < m and s[i][j + 1] == s[i][j]:
				x = -1
				break
		if x != 0:
			break
	if x == 0:
		print('YES')
		for i in s:
			print(''.join(i))
	else:
		print('NO')


n = int(input())

def solve():
	(r, w) = list(map(int, input().split()))
	matrix = []
	for i in range(r):
		line = input()
		matrix.append(line)
	odd = set()
	even = set()
	for i in range(r):
		for j in range(w):
			if i % 2 == j % 2:
				odd.add(matrix[i][j])
			else:
				even.add(matrix[i][j])
	if 'R' in odd and 'W' in odd or ('R' in even and 'W' in even) or ('W' in even and 'W' in odd) or ('R' in even and 'R' in odd):
		print('NO')
		return
	else:
		print('YES')
		if 'R' in even or 'W' in odd:
			t = 'RW' * (w + 2)
			for i in range(r):
				if i % 2 == 0:
					print(t[1:w + 1])
				else:
					print(t[:w])
		else:
			t = 'WR' * (w + 2)
			for i in range(r):
				if i % 2 == 0:
					print(t[1:w + 1])
				else:
					print(t[:w])
for i in range(n):
	solve()


T = int(input())
for _ in range(T):
	(n, m) = map(int, input().split())
	grid = [input() for i in range(n)]
	r_set = set()
	w_set = set()
	for i in range(n):
		for j in range(m):
			if grid[i][j] == 'R':
				r_set.add((i + j) % 2)
			if grid[i][j] == 'W':
				w_set.add((i + j) % 2)
	if max(len(r_set), len(w_set)) > 1 or len(r_set.intersection(w_set)) > 0:
		print('NO')
		continue
	if len(r_set) == 1:
		r = list(r_set)[0]
		w = 1 - r
	elif len(w_set) == 1:
		w = list(w_set)[0]
		r = 1 - w
	else:
		r = 0
		w = 1
	print('YES')
	for i in range(n):
		A = []
		for j in range(m):
			if r == (i + j) % 2:
				A.append('R')
			else:
				A.append('W')
		print(''.join(A))


t = int(input())

def solve():
	(n, m) = map(int, input().split())
	d = -1
	x = True
	for i in range(n):
		s = input()
		for j in range(m):
			cnt = i + j
			if s[j] != '.':
				if d == -1:
					d = cnt + (s[j] != 'R')
				elif s[j] == 'R':
					if (cnt - d) % 2 != 0:
						x = False
				elif (cnt - d) % 2 != 1:
					x = False
	if x:
		print('Yes')
		s = ''
		for i in range(n):
			for j in range(m):
				cnt = i + j
				if (d - cnt) % 2 == 0:
					s += 'R'
				else:
					s += 'W'
			s += '\n'
		print(s, end='')
	else:
		print('No')
for i in range(t):
	solve()


def f(n, m, l, x):
	if x:
		p = 'R'
	else:
		p = 'W'
	old = p
	for i in range(n):
		for j in range(m):
			if l[i][j] == p:
				if p == 'R':
					p = 'W'
				else:
					p = 'R'
			elif l[i][j] == '.':
				l[i][j] = p
				if p == 'R':
					p = 'W'
				else:
					p = 'R'
			else:
				return [False, 0]
		if old == 'W':
			p = 'R'
		else:
			p = 'W'
		old = p
	return [True, l]
for i in range(int(input())):
	(n, m) = map(int, input().split())
	lx1 = []
	for i in range(n):
		lx1.append(list(input()))
	lx2 = [x[:] for x in lx1]
	a = f(n, m, lx1, True)
	if a[0] == False:
		b = f(n, m, lx2, False)
		if b[0] == False:
			print('NO')
		else:
			l = b[1]
			print('YES')
			for i in l:
				print(''.join(i))
	else:
		l = a[1]
		print('YES')
		for i in l:
			print(''.join(i))


import sys
ins = lambda : sys.stdin.readline().strip()
inarr = lambda s: list(map(s, sys.stdin.readline().strip().split()))
outs = lambda n: sys.stdout.write(str(n) + '\n')
outarr = lambda li: sys.stdout.write(' '.join(map(str, li)) + '\n')
gcd = lambda a, b: b if a == 0 else gcd(b % a, a)

def color(arr, color, n, m):
	if color == 'W':
		opp = 'R'
	else:
		opp = 'W'
	for i in range(n):
		if i % 2 == 0:
			if arr[i][0].upper() == opp:
				return False
			else:
				arr[i][0] = color
		elif arr[i][0].upper() == color:
			return False
		else:
			arr[i][0] = opp
		for j in range(m):
			if j == 0:
				continue
			if arr[i][j - 1] == 'R':
				if arr[i][j] == 'R':
					return False
				else:
					arr[i][j] = 'W'
			elif arr[i][j] == 'W':
				return False
			else:
				arr[i][j] = 'R'
	return True

def out_mat(n, m, arr):
	outs('YES')
	for i in range(n):
		print(''.join(arr[i]))

def solve():
	(n, m) = inarr(int)
	flag = [_ for j in range(n)]
	for i in range(n):
		line = input()
		temp = []
		for j in range(len(line)):
			temp.append(line[j])
		flag[i] = temp
	flag1 = [_ for j in range(n)]
	for i in range(n):
		flag1[i] = flag[i][:]
	if color(flag, 'R', n, m):
		out_mat(n, m, flag)
		return
	if color(flag1, 'W', n, m):
		out_mat(n, m, flag1)
		return
	outs('NO')
	return
t = int(ins())
for _ in range(t):
	solve()


from sys import stdout, stdin, setrecursionlimit
from bisect import insort, bisect_right, bisect_left
from io import BytesIO, IOBase
from collections import *
from itertools import *
from random import *
from string import *
from queue import *
from heapq import *
from math import *
from re import *
from os import *

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = read(self._fd, max(fstat(self._fd).st_size, 8192))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = read(self._fd, max(fstat(self._fd).st_size, 8192))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(stdin, stdout) = (IOWrapper(stdin), IOWrapper(stdout))
(graph, mod, szzz) = ({}, 10 ** 9 + 7, lambda : sorted(zzz()))

def getStr():
	return input()

def getInt():
	return int(input())

def listStr():
	return list(input())

def getStrs():
	return input().split()

def isInt(s):
	return '0' <= s[0] <= '9'

def input():
	return stdin.readline().strip()

def zzz():
	return [int(i) for i in input().split()]

def output(answer, end='\n'):
	stdout.write(str(answer) + end)

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def primeNums():
	N = 10 ** 5
	SN = int(sqrt(N))
	sieve = [i for i in range(N + 1)]
	sieve[1] = 0
	for i in sieve:
		if i > SN:
			break
		if i == 0:
			continue
		for j in range(2 * i, N + 1, i):
			sieve[j] = 0
	prime = [i for i in range(N + 1) if sieve[i] != 0]
	return prime

def primeFactor(n):
	lst = []
	mx = int(sqrt(n)) + 1
	for i in prime:
		if i > mx:
			break
		while n % i == 0:
			lst.append(i)
			n //= i
	if n > 1:
		lst.append(n)
	return lst
dx = [-1, 1, 0, 0, 1, -1, 1, -1]
dy = [0, 0, 1, -1, 1, -1, -1, 1]
daysInMounth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
num = getInt()
for _ in range(num):
	(n, m) = zzz()
	lst1 = []
	lst2 = []
	lst3 = []
	ans = -1
	ans1 = ('RW' * ceil(m / 2))[:m]
	ans2 = ('WR' * ceil(m / 2))[:m]
	for i in range(n):
		if i % 2 == 0:
			lst1.append(ans1)
		else:
			lst1.append(ans2)
	for i in range(n):
		if i % 2:
			lst2.append(ans1)
		else:
			lst2.append(ans2)
	for i in range(n):
		arr = getStr()
		lst3.append(arr)
	ok1 = 1
	ok2 = 1
	for i in range(n):
		line1 = lst1[i]
		line2 = lst3[i]
		line3 = lst2[i]
		for (i, j, k) in zip(line1, line2, line3):
			if i == 'R' and (j != '.' and j != 'R'):
				ok1 = 0
			elif i == 'W' and (j != '.' and j != 'W'):
				ok1 = 0
			if k == 'R' and (j != '.' and j != 'R'):
				ok2 = 0
			elif k == 'W' and (j != '.' and j != 'W'):
				ok2 = 0
	if ok1:
		print('YES')
		for i in lst1:
			print(''.join(i))
	elif ok2:
		print('YES')
		for i in lst2:
			print(''.join(i))
	else:
		print('NO')


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	(n, m) = [int(x) for x in input().split()]
	arr = []
	for i in range(n):
		arr.append(input())
	(temp1, temp2) = ([[''] * m for i in range(n)], [[''] * m for i in range(n)])
	for i in range(n):
		for j in range(m):
			if (i + j) % 2:
				temp1[i][j] = 'R'
				temp2[i][j] = 'W'
			else:
				(temp1[i][j], temp2[i][j]) = ('W', 'R')
	(f1, f2) = (True, True)
	for i in range(n):
		for j in range(m):
			if arr[i][j] != '.':
				if arr[i][j] != temp1[i][j]:
					f1 = False
				if arr[i][j] != temp2[i][j]:
					f2 = False
	if f1 or f2:
		print('YES')
		if f1:
			for i in temp1:
				print(''.join(i))
		else:
			for i in temp2:
				print(''.join(i))
	else:
		print('NO')


test = int(input())

def createTable(n, m, k):
	ans = []
	for i in range(n):
		t = []
		count = k if i % 2 == 0 else 1 - k
		for j in range(m):
			t.append(count)
			count = 1 - count
		ans.append(t)
	w = []
	for i in range(n):
		t = ''
		for j in range(m):
			if ans[i][j]:
				t += 'W'
			else:
				t += 'R'
		w.append(t)
	return w

def same(a, b):
	(n, m) = (len(a), len(a[0]))
	for i in range(n):
		for j in range(m):
			if b[i][j] == '.':
				continue
			elif b[i][j] != a[i][j]:
				return False
	return True
for _ in range(test):
	(n, m) = map(int, input().split())
	matrix = []
	for i in range(n):
		matrix.append(input())
	white = createTable(n, m, 0)
	red = createTable(n, m, 1)
	if same(white, matrix):
		print('YES')
		for i in range(n):
			print(white[i])
	elif same(red, matrix):
		print('YES')
		for i in range(n):
			print(red[i])
	else:
		print('NO')


def generate_flag(first_row_is_white, colors):
	flag = []
	for i in range(n):
		new_row = []
		for j in range(m):
			selected_color = (j + i + first_row_is_white) % 2
			new_row.append(colors[selected_color])
		flag.append(new_row)
	return flag

def print_flag(flag):
	for row in flag:
		print(''.join(row))

def compare_flags(generated_flag, given_flag):
	for (row_1, row_2) in zip(generated_flag, given_flag):
		for (color_1, color_2) in zip(row_1, row_2):
			if color_2 != '.' and color_1 != color_2:
				return False
	return True
COLORS = 'WR'
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	first_option = generate_flag(True, COLORS)
	second_option = generate_flag(False, COLORS)
	given_flag = []
	for i in range(n):
		row = list(input())
		given_flag.append(row)
	if compare_flags(first_option, given_flag):
		print('YES')
		print_flag(first_option)
	elif compare_flags(second_option, given_flag):
		print('YES')
		print_flag(second_option)
	else:
		print('NO')


def switch(c):
	return 'R' if c == 'W' else 'W'

def task():
	(n, m) = map(int, input().split())
	grid = []
	for _ in range(n):
		grid.append(list(input()))
	first = None
	for i in range(n):
		for j in range(m):
			if grid[i][j] != '.':
				c = grid[i][j]
				if j % 2 == 1:
					c = switch(c)
				if i % 2 == 1:
					c = switch(c)
				first = c
				break
	if not first:
		first = 'R'
	result = []
	for i in range(n):
		fC = first
		res = ''
		for j in range(m):
			if grid[i][j] != '.' and grid[i][j] != fC:
				print('NO')
				return
			res += fC
			fC = switch(fC)
		result.append(res)
		first = switch(first)
	print('YES')
	for r in result:
		print(r)
t = int(input())
for _ in range(t):
	task()


def solve(n: int, m, g) -> None:
	one = []
	for i in range(n):
		tmp = []
		for j in range(m):
			if (i + j) % 2:
				tmp.append('R')
			else:
				tmp.append('W')
		one.append(tmp)
	two = []
	for i in range(n):
		tmp = []
		for j in range(m):
			if (i + j) % 2:
				tmp.append('W')
			else:
				tmp.append('R')
		two.append(tmp)
	one_pos = True
	two_pos = True
	for i in range(n):
		for j in range(m):
			if g[i][j] != '.' and g[i][j] != one[i][j]:
				one_pos = False
			if g[i][j] != '.' and g[i][j] != two[i][j]:
				two_pos = False
	if one_pos:
		print('YES')
		for i in range(n):
			print(''.join(one[i]))
		return
	if two_pos:
		print('YES')
		for i in range(n):
			print(''.join(two[i]))
		return
	print('NO')
	return
test_cases = int(input())
for _ in range(test_cases):
	(n, m) = list(map(int, input().split()))
	g = []
	for i in range(n):
		g.append(list(input()))
	solve(n, m, g)


t = int(input())
for p in range(t):
	n = list(map(int, input().split()))
	m = n[0]
	n = n[1]
	l = []
	if t > 100 or n > 50 or m > 50:
		print('NO')
		break
	flag = 1
	for i in range(m):
		l.append(list(input()))
	a1 = []
	e = 0
	for i in range(m):
		r = []
		for j in range(n):
			if i == 0:
				if e % 2 == 0:
					r.append('W')
				else:
					r.append('R')
				e += 1
			elif a1[i - 1][j] == 'R':
				r.append('W')
			else:
				r.append('R')
		a1.append(r)
		r = []
	a2 = []
	e = 0
	for i in range(m):
		r = []
		for j in range(n):
			if i == 0:
				if e % 2 == 0:
					r.append('R')
				else:
					r.append('W')
				e += 1
			elif a2[i - 1][j] == 'R':
				r.append('W')
			else:
				r.append('R')
		a2.append(r)
		r = []
	flag = 1
	for i in range(m):
		for j in range(n):
			if l[i][j] != '.' and l[i][j] != a1[i][j]:
				flag = 0
				break
		if flag == 0:
			break
	if flag == 1:
		print('YES')
		for i in a1:
			for j in i:
				print(j, end='')
			print()
	else:
		flag = 1
		for i in range(m):
			for j in range(n):
				if l[i][j] != '.' and l[i][j] != a2[i][j]:
					flag = 0
					break
			if flag == 0:
				break
		if flag == 0:
			print('NO')
		else:
			print('YES')
			for i in a2:
				for j in i:
					print(j, end='')
				print()


s = ['RW', 'WR']
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = [input() for i in range(n)]
	a = [(s[i & 1] * m)[:m] for i in range(n)]
	c = [(s[i + 1 & 1] * m)[:m] for i in range(n)]
	(b, d) = (1, 1)
	for i in range(len(l)):
		for j in range(len(l[i])):
			if l[i][j] != '.' and l[i][j] != a[i][j]:
				b = 0
			if l[i][j] != '.' and l[i][j] != c[i][j]:
				d = 0
	print('YES' if b or d else 'NO')
	if b:
		print(*a, sep='\n')
	elif d:
		print(*c, sep='\n')


from sys import stdin
_input = stdin.readline
(_range, _enumerate, _int, _str) = (range, enumerate, int, str)

def solution():
	for _ in _range(_int(_input())):
		(n, m) = [_int(i) for i in _input().split()]
		t = []
		arr = [['R' if i % 2 == 0 else 'W' for i in _range(m)]]
		arr.append(['R' if i % 2 != 0 else 'W' for i in _range(m)])
		even = [arr[0] if i % 2 == 0 else arr[1] for i in _range(n)]
		odd = [arr[0] if i % 2 != 0 else arr[1] for i in _range(n)]
		even_flag = True
		odd_flag = True
		for row in _range(n):
			t.append(_input().rstrip('\n'))
			for (index, ch) in _enumerate(t[-1]):
				if ch != '.':
					if ch != even[row][index]:
						even_flag = False
					if ch != odd[row][index]:
						odd_flag = False
		if even_flag or odd_flag:
			print('YES')
			if even_flag:
				for line in even:
					print(''.join(line))
			elif odd_flag:
				for line in odd:
					print(''.join(line))
		else:
			print('NO')
solution()


t = int(input())
for _ in range(t):
	flag = 0
	(n, m) = map(int, input().split())
	table = []
	for i in range(n):
		table.append(input())
	for i in range(n):
		for j in range(m):
			if table[i][j] == 'R':
				if (i + j) % 2 == 0:
					if flag == -1:
						flag = 2
						break
					flag = 1
				else:
					if flag == 1:
						flag = 2
						break
					flag = -1
			if table[i][j] == 'W':
				if (i + j) % 2 == 0:
					if flag == 1:
						flag = 2
						break
					flag = -1
				else:
					if flag == -1:
						flag = 2
						break
					flag = 1
		if flag == 2:
			break
	if flag == 2:
		print('NO')
	elif flag == -1:
		print('YES')
		for i in range(n):
			if i % 2 == 0:
				a = 0
			else:
				a = 1
			for j in range(m):
				if a == 1:
					print('R', end='')
					a = 0
				else:
					print('W', end='')
					a = 1
			print()
	else:
		print('YES')
		for i in range(n):
			if i % 2 == 0:
				a = 1
			else:
				a = 0
			for j in range(m):
				if a == 1:
					print('R', end='')
					a = 0
				else:
					print('W', end='')
					a = 1
			print()


import sys
MOD = 1000000007

def inp():
	return sys.stdin.readline().strip()

def ii():
	return int(inp())

def iis():
	return [int(i) for i in inp().split()]

def solve():
	(n, m) = iis()
	grid = [list(inp()) for _ in range(n)]
	popcnt = 0
	while grid[0].count('.') == m and popcnt < n:
		grid.append(grid[0])
		grid.pop(0)
		popcnt += 1
	if popcnt & 1 != 0:
		for j in range(n - popcnt):
			for k in range(m):
				if grid[j][k] != '.':
					grid[j][k] = 'R' if grid[j][k] == 'W' else 'W'
	possibles = [[], []]
	for i in range(m):
		if i & 1 == 0:
			possibles[0].append('R')
			possibles[1].append('W')
		else:
			possibles[0].append('W')
			possibles[1].append('R')
	possibleIdx = 0
	flipped = False
	out = []
	for i in range(n):
		for j in range(m):
			if grid[i][j] != '.' and grid[i][j] != possibles[possibleIdx][j]:
				possibleIdx = 1 - possibleIdx
				if (i != 0 or (i == 0 and flipped)) or grid[i][j] != possibles[possibleIdx][j]:
					print('NO')
					return
				flipped = True
		out.append(possibles[possibleIdx])
		possibleIdx = 1 - possibleIdx
	print('YES')
	for row in out:
		print(''.join(row))
t = ii()
for _ in range(t):
	solve()


def good(ans, goal):
	for i in range(len(ans)):
		if any((goal[i][j] != '.' and ans[i][j] != goal[i][j] for j in range(len(ans[i])))):
			return False
	return True

def solve(n, m, a):
	ans = [''.join(['W' if (i + j) % 2 == 0 else 'R' for j in range(m)]) for i in range(n)]
	if good(ans, a):
		return ans
	ans = [''.join(['R' if (i + j) % 2 == 0 else 'W' for j in range(m)]) for i in range(n)]
	if good(ans, a):
		return ans
	return None
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	s = [input() for i in range(n)]
	ans = solve(n, m, s)
	if ans != None:
		print('YES')
		for i in range(n):
			print(ans[i])
	else:
		print('NO')


for _ in range(int(input())):
	(r, c) = map(int, input().split())
	arr = []
	for i in range(r):
		arr.append(list(input()))
	white = []
	red = []
	flag = 0
	for i in range(r):
		for j in range(c):
			if arr[i][j] == 'R':
				red.append([i, j])
			elif arr[i][j] == 'W':
				white.append([i, j])
	if white == [] and red == []:
		for i in range(r):
			for j in range(c):
				if i % 2 == 0:
					if j % 2 == 0:
						arr[i][j] = 'W'
					else:
						arr[i][j] = 'R'
				elif j % 2 == 0:
					arr[i][j] = 'R'
				else:
					arr[i][j] = 'W'
	elif white == [] and red != []:
		ini = red[0]
		if ini[0] % 2 != ini[1] % 2:
			for i in range(r):
				for j in range(c):
					if i % 2 == 0:
						if j % 2 == 0:
							if arr[i][j] == 'R':
								flag = 1
								break
							arr[i][j] = 'W'
						else:
							if arr[i][j] == 'W':
								flag = 1
								break
							arr[i][j] = 'R'
					elif j % 2 == 0:
						if arr[i][j] == 'W':
							flag = 1
							break
						arr[i][j] = 'R'
					else:
						if arr[i][j] == 'R':
							flag = 1
							break
						arr[i][j] = 'W'
		else:
			for i in range(r):
				for j in range(c):
					if i % 2 == 0:
						if j % 2 == 0:
							if arr[i][j] == 'W':
								flag = 1
								break
							arr[i][j] = 'R'
						else:
							if arr[i][j] == 'R':
								flag = 1
								break
							arr[i][j] = 'W'
					elif j % 2 == 0:
						if arr[i][j] == 'R':
							flag = 1
							break
						arr[i][j] = 'W'
					else:
						if arr[i][j] == 'W':
							flag = 1
							break
						arr[i][j] = 'R'
	elif white != [] and red == []:
		ini = white[0]
		if ini[0] % 2 == ini[1] % 2:
			for i in range(r):
				for j in range(c):
					if i % 2 == 0:
						if j % 2 == 0:
							if arr[i][j] == 'R':
								flag = 1
								break
							arr[i][j] = 'W'
						else:
							if arr[i][j] == 'W':
								flag = 1
								break
							arr[i][j] = 'R'
					elif j % 2 == 0:
						if arr[i][j] == 'W':
							flag = 1
							break
						arr[i][j] = 'R'
					else:
						if arr[i][j] == 'R':
							flag = 1
							break
						arr[i][j] = 'W'
		else:
			for i in range(r):
				for j in range(c):
					if i % 2 == 0:
						if j % 2 == 0:
							if arr[i][j] == 'W':
								flag = 1
								break
							arr[i][j] = 'R'
						else:
							if arr[i][j] == 'R':
								flag = 1
								break
							arr[i][j] = 'W'
					elif j % 2 == 0:
						if arr[i][j] == 'R':
							flag = 1
							break
						arr[i][j] = 'W'
					else:
						if arr[i][j] == 'W':
							flag = 1
							break
						arr[i][j] = 'R'
	elif white != [] and red != []:
		ini = white[0]
		if ini[0] % 2 == ini[1] % 2:
			for i in range(r):
				for j in range(c):
					if i % 2 == 0:
						if j % 2 == 0:
							if arr[i][j] == 'R':
								flag = 1
								break
							arr[i][j] = 'W'
						else:
							if arr[i][j] == 'W':
								flag = 1
								break
							arr[i][j] = 'R'
					elif j % 2 == 0:
						if arr[i][j] == 'W':
							flag = 1
							break
						arr[i][j] = 'R'
					else:
						if arr[i][j] == 'R':
							flag = 1
							break
						arr[i][j] = 'W'
		else:
			for i in range(r):
				for j in range(c):
					if i % 2 == 0:
						if j % 2 == 0:
							if arr[i][j] == 'W':
								flag = 1
								break
							arr[i][j] = 'R'
						else:
							if arr[i][j] == 'R':
								flag = 1
								break
							arr[i][j] = 'W'
					elif j % 2 == 0:
						if arr[i][j] == 'R':
							flag = 1
							break
						arr[i][j] = 'W'
					else:
						if arr[i][j] == 'W':
							flag = 1
							break
						arr[i][j] = 'R'
	if flag == 1:
		print('NO')
	else:
		print('YES')
		for i in range(r):
			print(''.join(arr[i]))


def process(M):
	n = len(M)
	m = len(M[0])
	total_type = None
	for i in range(n):
		w_type = None
		for j in range(m):
			if M[i][j] == 'W':
				if j % 2 == 0:
					if w_type is None:
						w_type = 0
					elif w_type == 1:
						return ['NO', []]
				elif w_type is None:
					w_type = 1
				elif w_type == 0:
					return ['NO', []]
			if M[i][j] == 'R':
				if j % 2 == 0:
					if w_type is None:
						w_type = 1
					elif w_type == 0:
						return ['NO', []]
				elif w_type is None:
					w_type = 0
				elif w_type == 1:
					return ['NO', []]
		if w_type is not None:
			if w_type == i % 2:
				if total_type == 1:
					return ['NO', []]
				total_type = 0
			else:
				if total_type == 0:
					return ['NO', []]
				total_type = 1
	final_answer = []
	for i in range(n):
		this_row = ''
		if total_type is None or total_type == 0:
			w_type = i % 2
		else:
			w_type = 1 - i % 2
		for j in range(m):
			if j % 2 == w_type:
				this_row = this_row + 'W'
			else:
				this_row = this_row + 'R'
		final_answer.append(this_row)
	return ['YES', final_answer]
t = int(input())
for i in range(t):
	(n, m) = [int(x) for x in input().split()]
	M = []
	for j in range(n):
		M.append(input())
	(a1, a2) = process(M)
	print(a1)
	if len(a2) > 0:
		for x in a2:
			print(x)


import sys
MOD = 1000000007

def inp():
	return sys.stdin.readline().strip()

def ii():
	return int(inp())

def iis():
	return [int(i) for i in inp().split()]

def solve():
	(n, m) = iis()
	possibles = [[], []]
	for i in range(n):
		possibles[0].append((('WR' if i & 1 else 'RW') * (m // 2 + 1))[:m])
		possibles[1].append((('RW' if i & 1 else 'WR') * (m // 2 + 1))[:m])
	grid = [inp() for _ in range(n)]

	def test_grid(idx):
		for i in range(n):
			for j in range(m):
				if grid[i][j] != '.' and grid[i][j] != possibles[idx][i][j]:
					return False
		return True
	if test_grid(0):
		print('YES')
		return possibles[0]
	if test_grid(1):
		print('YES')
		return possibles[1]
	return ['NO']
t = ii()
for _ in range(t):
	print('\n'.join(solve()))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = []
	for i in range(n):
		l.append(str(input()))
	a = 'RW' * (k // 2) + 'R' * (k % 2)
	b = 'WR' * (k // 2) + 'W' * (k % 2)
	ans1 = []
	ans2 = []
	for i in range(n):
		if i % 2:
			ans1.append(b)
			ans2.append(a)
		else:
			ans1.append(a)
			ans2.append(b)
	aa = 1
	bb = 1
	for i in range(n):
		for j in range(k):
			if l[i][j] == '.':
				continue
			elif l[i][j] != ans1[i][j]:
				aa = 0
				break
		if aa == 0:
			break
	if aa == 1:
		print('YES')
		for i in ans1:
			print(i)
	else:
		for i in range(n):
			for j in range(k):
				if l[i][j] == '.':
					continue
				elif l[i][j] != ans2[i][j]:
					bb = 0
					break
			if bb == 0:
				break
		if bb == 0:
			print('NO')
		else:
			print('YES')
			for i in ans2:
				print(i)


t = int(input())

def binary_search(arr, low, high, x):
	if high >= low:
		mid = (high + low) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] > x:
			return binary_search(arr, low, mid - 1, x)
		else:
			return binary_search(arr, mid + 1, high, x)
	else:
		return -1
for _ in range(t):
	(n, m) = map(int, input().split())
	main = []
	find = 0
	e = 'R'
	o = 'W'
	ans = 1
	for i in range(n):
		s = input()
		for j in range(m):
			if find == 0 and s[j] != '.':
				if s[j] == 'W' and (i + j) % 2 == 0:
					(e, o) = (o, e)
				elif s[j] == 'R' and (i + j) % 2 == 1:
					(e, o) = (o, e)
				find = 1
			elif find == 1 and s[j] != '.':
				if (i + j) % 2 == 0:
					if s[j] != e:
						ans = 0
						break
				if (i + j) % 2 == 1:
					if s[j] != o:
						ans = 0
						break
	if ans == 0:
		print('NO\n')
		continue
	print('YES')
	for i in range(n):
		for j in range(m):
			if (i + j) % 2 == 0:
				print(e, end='')
			else:
				print(o, end='')
		print('\n')


def solve():
	(n, m) = map(int, input().split())
	case = -1
	grid = []
	for i in range(n):
		grid.append(input())
	for i in range(n):
		s = grid[i]
		for j in range(m):
			if s[j] == 'R':
				if case >= 0 and case != (i + j) % 2:
					return False
				case = (i + j) % 2
			elif s[j] == 'W':
				if case >= 0 and case != (i + j + 1) % 2:
					return False
				case = (i + j + 1) % 2
	one = 'RW' * (m // 2)
	two = 'WR' * (m // 2)
	if m & 1:
		one += 'R'
		two += 'W'
	if case == -1:
		case = 0
	ans = []
	for i in range(n):
		if i % 2 == case:
			ans.append(one)
		else:
			ans.append(two)
	return ans
T = int(input())
for i in range(T):
	temp = solve()
	if temp:
		print('yes')
		print('\n'.join(temp))
	else:
		print('no')


import math, copy
from collections import defaultdict, Counter

def fact(n):
	return 1 if n == 1 or n == 0 else n * fact(n - 1)

def SieveOfEratosthenes(n):
	l = []
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 1
	prime[0] = False
	prime[1] = False
	for p in range(n + 1):
		if prime[p]:
			l.append(p)
	return l

def inp():
	l = list(map(int, input().split()))
	return l
import math

def primeFactors(n, l):
	c = 0
	x = math.sqrt(n) + 1
	while n % 2 == 0:
		c += 1
		n = n / 2
	for i in range(1, len(l)):
		if l[i] > x:
			break
		while n % l[i] == 0:
			c += 1
			n = n / l[i]
	if n > 2:
		c += 1
	return c

def main():
	for _ in range(int(input())):
		(n, m) = inp()
		l = []
		p = ''
		f = True
		idx = 9999
		for i in range(n):
			s = list(input())
			if i == 0 or p == '':
				p = ''
				for j in range(m):
					if s[j] != '.':
						p = s[j]
						break
				if p != '':
					pp = p
					for x in range(j + 1, m):
						if s[x] == '.':
							if p == 'R':
								s[x] = 'W'
							else:
								s[x] = 'R'
							p = s[x]
						elif s[x] == p:
							f = False
							break
						else:
							p = s[x]
					p = pp
					for x in range(j - 1, -1, -1):
						if s[x] == '.':
							if p == 'R':
								s[x] = 'W'
							else:
								s[x] = 'R'
							p = s[x]
						elif s[x] == p:
							f = False
							break
						else:
							p = s[x]
					p = ''.join(s)
					l.append(p)
					if p[-1] == 'R':
						p += 'W'
					else:
						p += 'R'
					idx = i
				else:
					l.append([])
			elif p != '':
				if (i - idx) % 2 == 0:
					mm = p[:-1]
					for i in range(m):
						if s[i] != '.' and s[i] != mm[i]:
							f = False
							break
				else:
					mm = p[1:]
					for i in range(m):
						if s[i] != '.' and s[i] != mm[i]:
							f = False
							break
				l.append(mm)
			else:
				l.append([])
		if f:
			print('YES')
			if idx == 9999:
				p = 'RW' * m
				for i in range(n):
					if i % 2 == 0:
						l[i] = p[:m]
					else:
						l[i] = p[1:m + 1]
			elif idx != 0:
				for i in range(idx - 1, -1, -1):
					if (idx - i) % 2 == 0:
						l[i] = p[:-1]
					else:
						l[i] = p[1:]
			for i in l:
				print(i)
		else:
			print('NO')
import os, sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()

def random():
	rating = 100
	rating = rating * 100
	rating = rating * 100
	print(rating)

def random():
	rating = 100
	rating = rating * 100
	rating = rating * 100
	print(rating)

def random():
	rating = 100
	rating = rating * 100
	rating = rating * 100
	print(rating)

def random():
	rating = 100
	rating = rating * 100
	rating = rating * 100
	print(rating)


import sys
import io
import math
import collections
import decimal
import itertools
import bisect
import heapq

def input():
	return sys.stdin.readline()[:-1]
YES = 'YES'
NO = 'NO'

def solve(N, M, T):
	S0 = 'RW'
	S1 = 'WR'
	k = -1
	for i in range(N):
		for j in range(M):
			if T[i][j] == '.':
				continue
			if T[i][j] == 'R':
				k1 = (i + j) % 2
			else:
				k1 = (i + j + 1) % 2
			if k == -1:
				k = k1
			elif k != k1:
				print('NO')
				return
	print('YES')
	if k == -1 or k == 0:
		t = 0
	else:
		t = 1
	for i in range(N):
		L = []
		for j in range(M):
			L.append(S0[(i + j + t) % 2])
		print(''.join(L))
T0 = int(input())
for _ in range(T0):
	(N, M) = map(int, input().split())
	T = [input() for _ in range(N)]
	solve(N, M, T)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	check = False
	l = []
	m1 = []
	m2 = []
	mx1 = True
	mx2 = True
	for i in range(n):
		a = input()
		l.append(a)
	s = 'RW' * m
	for i in range(n):
		if i % 2 == 0:
			m1.append(s[:m])
			m2.append(s[1:m + 1])
		else:
			m1.append(s[1:m + 1])
			m2.append(s[:m])
	for i in range(n):
		for j in range(m):
			if l[i][j] != '.' and l[i][j] != m1[i][j]:
				check = True
				mx1 = False
				break
		if check:
			break
	if mx1:
		print('YES')
		for i in range(n):
			print(m1[i])
	else:
		check = False
		for i in range(n):
			for j in range(m):
				if l[i][j] != '.' and l[i][j] != m2[i][j]:
					check = True
					mx2 = False
					break
			if check:
				break
		if mx2:
			print('YES')
			for i in range(n):
				print(m2[i])
		else:
			print('NO')


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	l = []
	for i in range(n):
		s = input()
		l.append(list(s))

	def check(a, b):
		t = True
		for i in range(n):
			if i % 2 == 0:
				t = True
			else:
				t = False
			for j in range(m):
				if t:
					if l[i][j] == b:
						return False
				elif l[i][j] == a:
					return False
				t ^= True
		return True

	def fun(a, b):
		t = True
		for i in range(n):
			if i % 2 == 0:
				t = True
			else:
				t = False
			for j in range(m):
				if t:
					l[i][j] = a
				else:
					l[i][j] = b
				t ^= True
	flag = check('R', 'W')
	if flag:
		fun('R', 'W')
	else:
		flag = check('W', 'R')
		if flag:
			fun('W', 'R')
	if flag:
		print('YES')
		for i in range(n):
			print(''.join(l[i]))
	else:
		print('NO')