import sys
# input = sys.stdin.buffer.readline
def I(): return(list(map(int,input().split())))
def sieve(n):
	a=[1]*n
	for i in range(2,n):
	    if a[i]:
	        for j in range(i*i,n,i):
	            a[j]=0
	return a
def check(i,j):
	if matr[i][j]=="B":
		for x,y in (i+1,j),(i-1,j),(i,j-1),(i,j+1):
			if x>=0 and y>=0 and x<n and y<m:
				if (x,y)==(n-1,m-1):
					return False
				if matr[x][y]=="G":
					return False
	return True

for __ in range(int(input())):
	n,m=I()
	good=False
	matr=[[] for i in range(n)]
	for i in range(n):
		matr[i]=[j for j in input()]
		if not good:
			if "G" in matr[i]:
				good=True
	if not good:
		print("Yes")
		continue
	f=True
	for i in range(n):
		for j in range(m):
			if not check(i,j):
				f=False
				break
		if not f:
			break
	if f:
		print("Yes")
	else:
		print("No")






