import sys

def build_walls(i,j):
	visited = {(i,j)}
	q = [(i,j)]
	while q:
		i,j = q.pop()
		if i >= n or j >= m:
			continue
		if grid[i][j] == '#':
			continue
		if grid[i][j] == '.':
			grid[i][j] = '#'
			continue
		if (i+1,j) not in visited:
			visited.add((i+1,j))
			q.append((i+1,j))
		if (i,j+1) not in visited:
			visited.add((i,j+1))
			q.append((i,j+1))

def can_escape(c, expected):
	def dfs(i,j):
		ans = 0
		visited = {(i,j)}
		q = [(i,j)]
		while q:
			i,j = q.pop()
			if i < 0 or j < 0:
				continue
			if grid[i][j] == "#":
				continue
			if grid[i][j] == c:
				ans += 1
			if (i-1,j) not in visited:
				q.append((i-1,j))
				visited.add((i-1,j))
			if (i,j-1) not in visited:
				q.append((i,j-1))
				visited.add((i,j-1))
		return ans
	return dfs(len(grid)-1, len(grid[0])-1) == expected


t = int(sys.stdin.readline().strip())
for _ in range(t):
	n,m = list(map(int, sys.stdin.readline().strip().split(' ')))
	grid = []
	goods = 0
	bads = []
	empty = []
	for i in range(n):
		grid.append([c for c in sys.stdin.readline().strip()])
		for j,c in enumerate(grid[-1]):
			if c == 'G':
				goods += 1
			if c == 'B':
				bads.append((i,j))
			if c == '.':
				empty.append((i,j))
	for bad in bads:
		build_walls(bad[0], bad[1])

	if len(bads) > 0 and can_escape('B', len(bads)):
		print("No")
	else:
		if can_escape('G',goods):
			print("Yes")
		else:
			print("No")