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

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)


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]))


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())


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))


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])


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()


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 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])


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))


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())
	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='')


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)


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)


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')


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')


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 = ''


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()


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')


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')


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 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()


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])


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))


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')


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()


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()


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)


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')