import sys
input=sys.stdin.readline
def isvalid(i,j):
	if 0<=i<n and 0<=j<m:return True
	else:return False
def dfs(i,j):
	st=[(i,j)]
	while st:
		i,j=st.pop()
		if vis[i][j]==1 or w[i][j]==1:continue
		vis[i][j]=1
		if isvalid(i-1,j):st.append((i-1,j))
		if isvalid(i,j-1):st.append((i,j-1))
		if isvalid(i+1,j):st.append((i+1,j))
		if isvalid(i,j+1):st.append((i,j+1))


for _ in range(int(input())):
#	n=int(input())
	n,m=map(int,input().split())
#	s=input().strip()
#	a=list(map(int,input().split()))
	g=[]
	w=[[0 for j in range(m)] for i in range(n)]
	vis=[[0 for j in range(m)] for i in range(n)]
	for i in range(n):g.append(input())
	for i in range(n):
		for j in range(m):
			if g[i][j]=='B':
				if isvalid(i-1,j):w[i-1][j]=1
				if isvalid(i,j-1):w[i][j-1]=1
				if isvalid(i+1,j):w[i+1][j]=1
				if isvalid(i,j+1):w[i][j+1]=1
			elif g[i][j]=='#':w[i][j]=1
	dfs(n-1,m-1)
	f=0
	for i in range(n):
		for j in range(m):
			if g[i][j]=='G' and vis[i][j]==0:f=1;break
		if f:break
	if f:print('No')
	else:print('Yes')