#int(x) for x in input().split()
#map(int,input().split())
dx=[1,0,-1,0]
dy=[0,1,0,-1]
def bfs(l,gc):
	v=set()
	v.add((len(l)-1,len(l[0])-1))
	q=[(len(l)-1,len(l[0])-1)]
	gset=set()
	while q:
		(c,b)=q.pop(0)
		if l[c][b]=='G':
			gset.add((c,b))
		for j in range(4):
			nx=c+dx[j]
			ny=b+dy[j]
			if nx>=0 and nx<len(l) and ny>=0 and ny<len(l[0]) and l[nx][ny] in ['.','G']:
				if (nx,ny) not in v:
					v.add((nx,ny))
					q.append((nx,ny))
 
	return gc-len(gset)
 
 
import copy
for _ in range(int(input())):
	n,m=map(int,input().split())
	l=[]
	for i in range(n):
		l.append(list(input()))
 
	f=0
	gc=0
	for i in range(n):
		for j in range(m):
			if l[i][j]=='G':
				gc+=1
	for i in range(n):
		for j in range(m):
			if l[i][j]=='G':
				continue
			if l[i][j]=='B':
				for k in range(4):
					nx=i+dx[k]
					ny=j+dy[k]
					if nx>=0 and nx<len(l) and ny>=0 and ny<len(l[0]):
						if l[nx][ny]=='G':
							f=1
							break
						elif l[nx][ny]=='.':
							l[nx][ny]='#'
		if f:
			break
 
 
 
	if gc==0:
		print('Yes')
		continue

	if f or l[-1][-1]=='#':
		print('No')
		continue

 
	if bfs(l,gc)==0:
		print('Yes')
	else:
		print('No')