# from functools import lru_cache
from sys import stdin, stdout
import sys
from math import *
from collections import deque
# sys.setrecursionlimit(3*int(1e5))
input = stdin.readline
# print = stdout.write
 
# @lru_cache()

def bfs(i,j,ar):
	n=len(ar)
	m=len(ar[0])-1
	# print(n,m)
	q1=deque()
	q2=deque()
	q1.append(i)
	q2.append(j)
	# print(i,j)
	v[i][j]=1
	while(len(q1)>0):
		x=q1.popleft()
		y=q2.popleft()
		if(x<n-1 and ar[x+1][y]!='#' and v[x+1][y]==0):
			v[x+1][y]=1
			q1.append(x+1)
			q2.append(y)
		if(x>0 and ar[x-1][y]!='#' and v[x-1][y]==0):
			v[x-1][y]=1
			q1.append(x-1)
			q2.append(y)
		if(y<m-1 and ar[x][y+1]!='#' and v[x][y+1]==0):
			v[x][y+1]=1
			q1.append(x)
			q2.append(y+1)
		if(y>0 and ar[x][y-1]!='#' and v[x][y-1]==0):
			v[x][y-1]=1
			q1.append(x)
			q2.append(y-1)
	return False


for __ in range(int(input())):
	n,m=map(int,input().split())
	ar=[]
	v=[]
	for i in range(n):
		ar.append(list(input()))
		v.append([0]*m)
	for i in range(n):
		for j in range(m):
			if(ar[i][j]=='B'):
				if(i<n-1 and ar[i+1][j]=='.'):
					ar[i+1][j]="#"
				if(i>0 and ar[i-1][j]=='.'):
					ar[i-1][j]='#'
				if(j<m-1 and ar[i][j+1]=='.'):
					ar[i][j+1]='#'
				if(j>0 and ar[i][j-1]=='.'):
					ar[i][j-1]='#'
	rslt=0
	if(ar[n-1][m-1]=='.'):
		bfs(n-1,m-1,ar)
	for i in range(n):
		for j in range(m):
			if(ar[i][j]=='G'):
				ans=v[i][j]==1
				if(ans==False):
					rslt=1
					break
				else:
					if(i<n-1 and ar[i+1][j]=='B'):
						rslt=1
						break
					if(i>0 and ar[i-1][j]=='B'):
						rslt=1
						break
					if(j<m-1 and ar[i][j+1]=='B'):
						rslt=1
						break
					if(j>0 and ar[i][j-1]=='B'):
						rslt=1
						break
		if(rslt==1):
			break
	if(rslt==0):
		print("Yes")
	else:
		print("No")



	