# Problem: D. Solve The Maze
# Contest: Codeforces - Codeforces Round #648 (Div. 2)
# URL: https://codeforces.com/contest/1365/problem/D
# Memory Limit: 256 MB
# Time Limit: 1000 ms
# 
# KAPOOR'S

from sys import stdin, stdout 

def INI():
	return int(stdin.readline())
	
def INL():
	return [int(_) for _ in stdin.readline().split()]
	
def INS():
	return stdin.readline()

def MOD():
    return pow(10,9)+7
	
def OPS(ans):
	stdout.write(str(ans)+"\n")
	
def OPL(ans):
	[stdout.write(str(_)+" ") for _ in ans]
	stdout.write("\n")

def make(i,j):
	if 0<=i-1<n and 0<=j<m and X[i-1][j]==".":
		X[i-1][j]="#"
	if 0<=i+1<n and 0<=j<m and X[i+1][j]==".":
		X[i+1][j]="#"
	if 0<=i<n and 0<=j-1<m and X[i][j-1]==".":
		X[i][j-1]="#"
	if 0<=i<n and 0<=j+1<m and X[i][j+1]==".":
		X[i][j+1]="#"

def is_safe(i,j):
	return 0<=i<n and 0<=j<m 	
	
def dfs(i,j):
	global ans
	if X[i][j]=="G":
		ans-=1
	V[i][j]=True
	
	for _,__ in [[i-1,j],[i+1,j],[i,j+1],[i,j-1]]:
		if is_safe(_,__) and not V[_][__]:
			if X[_][__]=="B":
				global f
				f=1
			elif X[_][__] in ".G":
				dfs(_,__)
	
	
if __name__=="__main__":
	for _ in range(INI()):
		n,m=INL()
		X=[]
		V=[[False for _ in range(m)] for _ in range(n)]
		ans=0
		f=0
		for _ in range(n):
			x=list(input())
			ans+=x.count('G')
			X.append(x)
		
		for _ in range(n):
			for __ in range(m):
				if X[_][__]=='B':
					make(_,__)
		if X[n-1][m-1]!="#":
			dfs(n-1,m-1)	
		
		# print(V)
		if not ans and not f:
			OPS('Yes')
		else:
			OPS('No')
			