'''input
6
1 1
.
1 2
G.
2 2
#B
G.
2 3
G.#
B#.
3 3
#B.
#..
GG.
2 2
#B
B.
'''
import sys
input = sys.stdin.readline

for t in range(int(input())):
	n,m = list(map(int, input().split()))
	data = [ list(input().strip()) for i in range(n)]

	    
	allowed  = ['G','B', '.']
	directions = [(0,1),(1,0),(0,-1),(-1,0)]
	corners = [(1,1),(1,-1)] 
	def valid(i,j):
	    return 0<=i<n and 0<=j<m and data[i][j] in allowed

	def dfs(i,j,mark):
		#print(i,j,mark)
		#if mark[i][j]: return True
		mark[i][j]=1
		if i==n-1 and j==m-1:
			#print('Yo')
			return True
		ans = False 
		for x,y in directions:
			#print(x+i,y+j, valid(x+i,y+j), not mark[x+i][y+j] if valid(x+i,y+j) else 'False')
			if valid(x+i,y+j) and not mark[x+i][y+j]:
				temp=dfs(x+i,y+j,mark)
				ans = ans or temp
		return ans

	for i in range(n):
		for j in range(m):
			if data[i][j]=='B':
				for x,y in directions:
					if valid(i+x,j+y) and data[i+x][j+y]=='.':
					    data[i+x][j+y]='#'

	# for line in data:
	# 	print(*line)

	mark = [[0]*m for i in range(n)]
	flag1 = True
	for i in range(n):  
		for j in range(m):
			if data[i][j]=='G' and not mark[i][j]:
				#print('start',i,j,mark)
				ans = dfs(i,j,mark)
				#print('ans',i,j,ans)
				if not ans: 
					flag1 = False 


	mark = [[0]*m for i in range(n)] 
	flag2 = True
	for i in range(n):  
		for j in range(m):
		    if data[i][j]=='B' and not mark[i][j]:
		        ans = dfs(i,j,mark)
		        #print(i,j,ans)
		        if ans: 
		            flag2 = False 


	#print(flag1, flag2)
	print( 'Yes' if all((flag1, flag2)) else 'No') 
