# for fast pow :- use math.pow(x,y) O(1) return value in float

from collections import defaultdict as dft
import sys
import math
def ml():return list(map(int,input().split()))
def mp(): return map(int,input().split())
def debug(name,val):print(name,':',val)
sys.setrecursionlimit(10**5)
#input=sys.stdin.readline
 
def bfs(x,y,posi,dr,n,m,grid):
    posi[x][y]=1
    for i,j in dr:
        if 0<=i+x<n and 0<=j+y<m:
            if grid[i+x][j+y] =="#" or posi[i+x][j+y]:
                continue
            bfs(i+x,j+y,posi,dr,n,m,grid)
    
def solve():
    n,m=map(int,input().split())
    grid=[]
    cg=0
    for i in range(n):
        ls=list(input())
        cg+=ls.count("G")
        grid.append(ls)
    if cg==0:
        #print(cg)
        return True
    dr=[[1,0],[0,1],[-1,0],[0,-1]]
    for i in range(n):
        for j in range(m):
            if grid[i][j]=="B":
                for x,y in dr:
                    if 0<=i+x<n and 0<=j+y<m:
                        if grid[i+x][j+y]=="G":
                            return False
                        if grid[i+x][j+y]==".":
                            grid[i+x][j+y]="#"
    
    if grid[n-1][m-1]=="#":
        return False
    posi=[[0 for i in range(m)] for j in range(n)]
    bfs(n-1,m-1,posi,dr,n,m,grid)
    #print(posi)
    for i in range(n):
        for j in range(m):
            if grid[i][j]=="G":
                if posi[i][j]==0:
                    return False
 
    
    return True
 
t=int(input())
for _ in range(t):
    if solve():
        print("Yes")
    else:
        print("No")