import sys
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
I = lambda : list(map(int,input().split()))

t, = I()
for _ in range(t):
	n,m = I()
	l=[];cg=cb=0
	for i in range(n):
		s=list(input().strip())
		l.append(s)
		cg+=s.count('G')
		cb+=s.count('B')
	for i in range(n):
		for j in range(m):
			if l[i][j]=='B':
					xt=0;x=i;y=j
					if x+1<n and (l[x+1][y] not in ['G','B']):
						l[x+1][y]='#'
					if y+1<m and (l[x][y+1] not in ['G','B']):
						l[x][y+1]='#'
					if x-1>=0 and (l[x-1][y] not in ['G','B']):
						l[x-1][y]='#'
					if y-1>=0 and (l[x][y-1] not in ['G','B']):
						l[x][y-1]='#'
	if cg==0:
		print("Yes")
	elif (n>=2 and m>=2 ) and (l[n-2][m-1]=='B' or l[n-1][m-2]=='B'):
		print("No")
	else:
		tt=[[0]*m for i in range(n)]
		def dfs(x,y,i,mt):
			mt[x][y]=i
			if x+1<n and mt[x+1][y]==0 and (l[x+1][y] not in ['#','B']):
				mt[x+1][y]=i;dfs(x+1,y,i,mt)
			if y+1<m and mt[x][y+1]==0 and (l[x][y+1] not in ['#','B']):
				mt[x][y+1]=i;dfs(x,y+1,i,mt)
			if x-1>=0 and mt[x-1][y]==0 and (l[x-1][y] not in ['#','B']):
				mt[x-1][y]=i;dfs(x-1,y,i,mt)
			if y-1>=0 and mt[x][y-1]==0 and (l[x][y-1] not in ['#','B']):
				mt[x][y-1]=i;dfs(x,y-1,i,mt)
		dfs(n-1,m-1,2,tt)
		ct=0
		for i in range(n):
			for j in range(m):
				if l[i][j]=='G':
					xt=0;x=i;y=j
					if x+1<n and l[x+1][y]=='B':
						xt+=1
					if y+1<m and l[x][y+1]=='B':
						xt+=1
					if x-1>=0 and l[x-1][y]=='B':
						xt+=1
					if y-1>=0 and l[x][y-1]=='B':
						xt+=1			
					if tt[i][j]!=2 or xt!=0:
						ct+=1;break
			if ct:
				break
		#print(l)
		if ct:
			print("No")
		elif cb==0:
			print("Yes")
		else:
			f=0
			print("YNeos"[f::2])
