import collections

def neighors(cur,mat,allowed):
	i,j = cur
	res = []
	for nei in [(i+1,j), (i,j-1), (i-1,j), (i,j+1)]:
		if 0<=nei[0] < len(mat) and 0<= nei[1] < len(mat[0]):
			if mat[nei[0]][nei[1]] in allowed:
				res.append(nei)
	return res
def f(mat):
	good = 0
	flag = False
	for i in range(len(mat)):
		for j in range(len(mat[0])):
			if mat[i][j] == 'B':
				for nei in neighors((i,j), mat, set(['.','G'])):
					if mat[nei[0]][nei[1]] == 'G':
						flag = True 
					mat[nei[0]][nei[1]] = '#'
			if mat[i][j] == 'G':
				good  +=1

	if flag:
		return False
	q =collections.deque([(len(mat)-1, len(mat[0]) -1 )])
	if mat[q[0][0]][q[0][1]] != '.': q.popleft()
	vis = set([])
	while(q) :
		cur = q.popleft()
		vis.add(cur)
		for u in neighors(cur, mat, set(['.', 'G'])):
			if u not in vis:
				vis.add(u)
				q.append(u)

	return len([1 for u in vis if mat[u[0]][u[1]] == 'G' ]) == good
nt = int(raw_input())
for tc in range(nt):
	r,c = map(int, raw_input().split(' '))
	mat  = [list(raw_input()) for _ in range(r)]
	"""
	print 'here is the original'
	for l in mat:
		print l
	"""
	ans =  'Yes' if f(mat) else 'No'
	print ans
	"""
	print 'here is the modified:'
	for l in mat:
		print l
	"""