import sys
LI=lambda:list(map(int, sys.stdin.readline().strip('\n').split()))
MI=lambda:map(int, sys.stdin.readline().strip('\n').split())
SI=lambda:sys.stdin.readline().strip('\n')
II=lambda:int(sys.stdin.readline().strip('\n'))

def check(i, j):
	global n, m, g, vis
	return 0<=i<n and 0<=j<m and g[i][j]!='#' and not vis[i][j]

for _ in range(II()):
	n, m=MI()
	g, num=[], 0
	for i in range(n):
		g.append(list(SI()))
		num+=g[-1].count('G')
	for i in range(n):
		for j in range(m):
			if g[i][j]=='B':
				if i+1<n and g[i+1][j]!='B':
					g[i+1][j]='#'
				if i-1>=0 and g[i-1][j]!='B':
					g[i-1][j]='#'
				if j+1<m and g[i][j+1]!='B':
					g[i][j+1]='#'
				if j-1>=0 and g[i][j-1]!='B':
					g[i][j-1]='#'
	# print(g)
	q, vis=[(n-1, m-1)], [[False for j in range(m)] for i in range(n)]
	cnt=0
	# print(g)
	# print(vis)
	if g[n-1][m-1]!='#':
		while q:
			u, v=q.pop()
			# print(u, v)
			if vis[u][v]:
				continue
			vis[u][v]=True
			if g[u][v]=='G':
				cnt+=1
			if check(u+1, v):
				q.append((u+1, v))
			if check(u-1, v):
				q.append((u-1, v))
			if check(u, v+1):
				q.append((u, v+1))
			if check(u, v-1):
				q.append((u, v-1))
	print('Yes' if cnt==num else 'No')
	# print(cnt, num)