import os, sys

raw_input = sys.stdin.readline

def try_to_escape(maze, visited, x, y):

	G_number = 0
	visited[(x, y)] = 1
	if maze[x][y] == "G": 
		G_number = 1

	try:
		if visited.get((x+1, y), 0) == 0 and maze[x+1][y] in ".G":
			G_number += try_to_escape(maze, visited, x + 1, y)
	except: pass

	try:
		if x > 0:
			if visited.get((x-1, y), 0) == 0 and maze[x-1][y] in ".G":
				G_number += try_to_escape(maze, visited, x - 1, y)
	except: pass

	try:
		if visited.get((x, y + 1), 0) == 0 and maze[x][y+1] in ".G":
			G_number += try_to_escape(maze, visited, x, y+1)
	except: pass
	
	try:
		if y > 0:
			if visited.get((x, y-1), 0) == 0 and maze[x][y-1] in ".G":
				G_number += try_to_escape(maze, visited, x, y-1)
	except: pass

	return G_number

t = int(raw_input())
for t_itr in xrange(t):
	n, m = map(int, raw_input().split())
	maze = []
	
	G_number = 0
	for n_itr in xrange(n):
		row = list(raw_input().strip())
		maze.append(row)

		for cell in row:
			if cell == 'G':
				G_number +=1

	is_blocked =  True
	for n_itr in xrange(n):
		for m_itr in xrange(m):
			if maze[n_itr][m_itr] == 'B':
				try: 
					if maze[n_itr+1][m_itr] == 'G':
						is_blocked = False
					elif maze[n_itr+1][m_itr] == ".":
						maze[n_itr+1][m_itr] = "#"
				except: pass

				try: 
					if n_itr > 0:
						if maze[n_itr - 1][m_itr] == 'G':
							is_blocked = False
						elif maze[n_itr - 1][m_itr] == ".":
							maze[n_itr - 1][m_itr] = "#"
				except: pass

				try:
					if m_itr > 0: 
						if maze[n_itr][m_itr - 1] == 'G':
							is_blocked = False
						elif maze[n_itr][m_itr - 1] == ".":
							maze[n_itr][m_itr - 1] = "#"
				except: pass

				try: 
					if maze[n_itr][m_itr + 1] == 'G':
						is_blocked = False
					elif maze[n_itr][m_itr + 1] == ".":
						maze[n_itr][m_itr + 1] = "#"
				except: pass

				if is_blocked == False:
					break

	visited = {}
	ans = 0
	if maze[n-1][m-1] == ".":
		ans = try_to_escape(maze, visited, n-1, m-1)
	if ans == G_number and is_blocked == True:
		print ('Yes')
	else:
		print ('No')
				
				