'''input
6
1 1
.
1 2
G.
2 2
#B
G.
2 3
G.#
B#.
3 3
#B.
#..
GG.
2 2
#B
B.

'''
from sys import stdin,stdout
I = lambda : map(int,stdin.readline().split())
import bisect
import math

def anypath(a,n,m):
	visited = []
	for i in range(n):
		visited.append([0]*m)
	q = [[n-1,m-1]]
	ret = 0
	while len(q)!=0:
		x,y = q.pop()
		if visited[x][y] or a[x][y] == '#':
			continue
		else:
			i,j = x,y
			if i!=0:
				if a[i-1][j] != '#':
					q.append([i-1,j])
			if i!=n-1:
				if a[i+1][j] != '#':
					q.append([i+1,j])
			if j!=0:
				if a[i][j-1] != '#':
					q.append([i,j-1])
			if j!=m-1:
				if a[i][j+1] != '#':
					q.append([i,j+1])
		# print q
		if a[x][y] == 'G':
			ret+=1
		visited[x][y] = 1
	return ret	



t = input()
for _ in range(t):
	n,m = I()
	a = []
	for i in range(n):
		a.append(list(raw_input()))
	np = 0
	cnt = 0
	for i in range(n):
		for j in range(m):
			if a[i][j] == 'G':
				cnt+=1
			if a[i][j] == 'B':
				# blockedges and if g in edges return flase
				if i!=0:
					if a[i-1][j] == 'G':
						np = 1
					elif a[i-1][j] == '.':
						a[i-1][j] = '#'
				if i!=n-1:
					if a[i+1][j] == 'G':
						np = 1
					elif a[i+1][j] == '.':
						a[i+1][j] = '#'
				if j!=0:
					if a[i][j-1] == 'G':
						np = 1
					elif a[i][j-1] == '.':
						a[i][j-1] = '#'
				if j!=m-1:
					if a[i][j+1] == 'G':
						np = 1
					elif a[i][j+1] == '.':
						a[i][j+1] = '#'
			if np:
				break
		if np:
			break			
	if np:
		print "No"
	else:
		# check if there is a path to all g
		if cnt == anypath(a,n,m):
			print "Yes"
		else:
			print "No"
		# print anypath(a,n,m)