
def	check_by_a_star(x, y, out_x, out_y, visited, maze):
	next_node = [] # index and dest
	while x != out_x or y != out_y:
		if len(next_node):
			visited.append(next_node[0])
			next_node.pop(0)
		if x + 1 <= out_x and maze[y][x + 1] != '#' and [y, x + 1] not in visited and [y, x + 1] not in next_node:
			dest = abs(out_x - x - 1) + abs (out_y - y)
			next_node.insert(-1, [y, x + 1, dest])
		if x - 1 >= 0 and maze[y][x - 1] != '#' and [y, x - 1] not in visited and [y, x + 1] not in next_node:
			dest = abs(out_x - x + 1) + abs (out_y - y)
			next_node.insert(-1, [y, x - 1, dest])

		if y + 1 <= out_y and maze[y + 1][x] != '#' and [y + 1, x] not in visited  and [y + 1, x] not in next_node:
			dest = abs(out_x - x) + abs (out_y - y - 1)
			next_node.insert(-1, [y + 1, x, dest])
		if y - 1 >= 0 and maze[y - 1 ][x] != '#' and [y - 1, x] not in visited  and [y - 1, x] not in next_node:
			dest = abs(out_x - x) + abs (out_y - y + 1)
			next_node.insert(-1, [y - 1, x, dest])
		next_node = sorted(next_node, key = lambda x : x[2])
		if (len(next_node) == 0):
			return 0
		x = next_node[0][1]
		y =  next_node[0][0]
	return 1

	

t = int(input())
ans = []
for tt in range(t):
	n,m = map(int, input().split())
	maze = []
	g_p = []
	b_p = []
	out_p = []
	check = 1
	for j in range(n):
		line = input()
		maze.append(list(line))
		for i in range(m):
			c = line[i]
			if c == 'G':
				g_p.append([j, i])
			if c == 'B':
				b_p.append([j, i])
	if len(g_p) == 0:
		print('Yes')
		check = 0
		continue

	out_x = m - 1
	out_y = n - 1
	points = []
	for bad in b_p:
		x_b = bad[1]
		y_b = bad[0]
	

		if x_b + 1 <= out_x and maze[y_b][x_b + 1] != '#':
			points.append([x_b + 1, y_b])
		if x_b - 1 >= 0 and maze[y_b][x_b - 1] != '#':
			points.append([x_b - 1, y_b])
		if y_b + 1 <= out_y and maze[y_b + 1][x_b] != '#':
			points.append([x_b, y_b + 1])
		if y_b - 1 >= 0 and maze[y_b - 1][x_b] != '#':
			points.append([x_b, y_b - 1])


		for p in points:
			px = p[0]
			py = p[1]
			if maze[py][px] == '.' and (px != out_x or py != out_y):
				maze[py][px] = '#'
			elif maze[py][px] == 'G' or (py == out_y and px == out_x) or (px == out_x and py == out_y):
				check  = 0
				print('No')
				break
		if check == 0:
			break
	if check == 0:
		continue

	'''for g in g_p:
		x_g = g[1]
		y_g = g[0]
		visited = []
		next_node = []
		visited.append([y_g, x_g])
#		if check_if_it_is_valid(m - 1, n - 1, x_g, y_g, maze,visited,next_node) == 0:
		if check_by_a_star(x_g, y_g, m - 1, n - 1, visited, maze) == 0:
			print('No')
			check = 0
			break'''
	if check:
		print('Yes')
