#: Author - Soumya Saurav
import sys,io,os,time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq
alphabet = "abcdefghijklmnopqrstuvwxyz"

input = sys.stdin.readline

########################################

dirr = [[1,0], [0,1] , [-1,0], [0,-1]]

def valid(i,j,n,m):
	return 0 <= i <= n-1 and 0 <= j <= m-1

for ii in range(int(input())):
	n , m = map(int , input().split())
	arr = [list(input()) for i in range(n)]
	visited = [[False]*(m+1) for i in range(n+1)]
	for i in range(n):
		for j in range(m):
			if arr[i][j] == "B":
				for x,y in dirr:
					nx = x+i
					ny = y+j
					if valid(nx,ny,n,m) and arr[nx][ny] == ".":
						arr[nx][ny] = "#"
	q = deque()
	if arr[n-1][m-1] == ".":
		q.append([n-1,m-1])
		visited[n-1][m-1] = True
	while q:
		i , j = q.popleft()
		for x, y in dirr:
			nx = i+x
			ny = j+y
			if valid(nx,ny,n,m) and not visited[nx][ny] and arr[nx][ny] != "#":
				q.append([nx,ny])
				visited[nx][ny] = True
	ok = True
	for i in range(n):
		for j in range(m):
			if (arr[i][j] == "G" and not visited[i][j]) or (arr[i][j] == "B" and visited[i][j]):
				ok = False
				break
	if ok:
		print("Yes")
	else:
		print("No")
	
	





