def bfs(r,c,ct):
	row=[]
	col=[]
	row.append(r)
	col.append(c)
	while (len(row)!=0):
		r=row[0]
		c=col[0]
		row.pop(0)
		col.pop(0)
		visit[r][c]=1
		# print(row)
		# print(col)
		# print(r,c,matrix[r][c])
		if matrix[r][c]=="G":
			ct-=1

		if r!=0 and (matrix[r-1][c]!="#") and visit[r-1][c]==0:
			row.append(r-1)
			col.append(c)
		if c!=m-1 and (matrix[r][c+1]!='#') and visit[r][c+1]==0:
			row.append(r)
			col.append(c+1)

		if r!=n-1 and (matrix[r+1][c]!='#') and visit[r+1][c]==0:
			row.append(r+1)
			col.append(c)

		if c!=0 and (matrix[r][c-1]!='#') and visit[r][c-1]==0:
			row.append(r)
			col.append(c-1)
	return ct

def bfs_(r,c):
	row=[]
	col=[]
	row.append(r)
	col.append(c)
	while (len(row)!=0):
		r=row[0]
		c=col[0]
		row.pop(0)
		col.pop(0)
		visit[r][c]=1
		if matrix[r][c]=="B":
			return 0

		if r!=0 and (matrix[r-1][c]=='B' or matrix[r-1][c]=='G') and visit[r-1][c]==0:
			row.append(r-1)
			col.append(c)
		if c!=m-1 and (matrix[r][c+1]=='B' or matrix[r][c+1]=='G') and visit[r][c+1]==0:
			row.append(r)
			col.append(c+1)

		if r!=n-1 and (matrix[r+1][c]=='B' or matrix[r+1][c]=='G') and visit[r+1][c]==0:
			row.append(r+1)
			col.append(c)

		if c!=0 and (matrix[r][c-1]=='B' or matrix[r][c-1]=='G') and visit[r][c-1]==0:
			row.append(r)
			col.append(c-1)

	return 1


	


for t in range(int(input())):
	# n=int(input())
	n,m = map(int,input().split())
	ct=0
	matrix = [0]*n
	visit =[[0 for i in range(m)] for i in range(n)]
	for i in range(n):
		matrix[i]=input().strip()
	
	checkb = bfs_(n-1,m-1)
	for i in range(n):
			for j in range(m):
				if matrix[i][j]=="G":
					ct+=1
	if checkb==0:
		if ct==0 and matrix[n-1][m-1]==".":
			print("Yes")
		else:
			print("No")
	else:
		visit =[[0 for i in range(m)] for i in range(n)]
		

		wt=bfs(n-1,m-1,ct)
		if wt<=0:
			print("Yes")
		else:
			# print(wt)
			print("No")