'''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
sys.setrecursionlimit(100000)

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)]
	def valid(i,j):
	    return 0<=i<n and 0<=j<m and data[i][j] in allowed

	def dfs(i,j,mark):
		mark[i][j]=1
		for x,y in directions:
			if valid(x+i,y+j) and not mark[x+i][y+j]:
				dfs(x+i,y+j,mark)	

	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]='#'

	mark = [[0]*m for i in range(n)]
	if data[n-1][m-1]!='#':
		dfs(n-1,m-1,mark)

	flag1 = True
	for i in range(n):  
		for j in range(m):
			if data[i][j]=='G' and not mark[i][j]:
				flag1 = False 

	flag2 = True
	for i in range(n):  
		for j in range(m):
		    if data[i][j]=='B' and mark[i][j]:
		    	flag2 = False 


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