from sys import stdin
input = stdin.readline

g = []
vis = []
dx = [0, 0, 1, -1]
dy = [1, -1, 0, 0]


def dfs(s):
	q = [s]
	vis[s[0]][s[1]] = 1
	#print(g, vis, n, m)
	while q:
		x, y = q.pop()
		for i in range(4):
			if 0 <= x + dx[i] < n and 0 <= y + dy[i] < m:
				if not vis[x + dx[i]][y + dy[i]] and g[x + dx[i]][y + dy[i]] not in 'B#':
					vis[x + dx[i]][y + dy[i]] = 1, q.append((x + dx[i], y + dy[i]))

for _ in range(int(input())):
	#global g, vis, n, m
	n, m = map(int, input().split())
	gg = [list(input()[:-1]) for i in range(n)]
	g = [[gg[i][j] for j in range(m)] for i in range(n)]
	cnt = 0
	for i in g:
		cnt += i.count('G')
	if not cnt:
		print('Yes')
		continue
	for x in range(n):
		for y in range(m):
			if gg[x][y] == 'B':
				for i in range(4):
					if 0 <= x + dx[i] < n and 0 <= y + dy[i] < m:
						if g[x + dx[i]][y + dy[i]] == '.':
							g[x + dx[i]][y + dy[i]] = 'B'
							break
	if g[n - 1][m - 1] == 'B':
		print('No')
		continue
	
	vis = [[0 for j in range(m)] for i in range(n)]
	#print(vis)
	
	if g[n - 1][m - 1] in 'G.':
		g[n - 1][m - 1] = 'G'
		dfs((n - 1, m - 1))
	#print(g)
	flag = 1
	for x in range(n):
		for y in range(m):
			if g[x][y] == 'G':
				if not vis[x][y]:
					flag = 0
					break
				for i in range(4):
					if 0 <= x + dx[i] < n and 0 <= y + dy[i] < m:
						if g[x + dx[i]][y + dy[i]] == 'B':
							flag = 0
							break
		if not flag:
			break
	if flag:
		print('Yes')
	else:
		print('No')

