 
def crawl(i,j,a):
     dp[i][j]=1
     if i>0 and a[i-1][j]!="B" and a[i-1][j]!="#":
         crawl(i-1,j,a)
     if j>0 and a[i][j-1]!="B" and a[i][-1+j]!="#":
         crawl(i,j-1,a)


dp=[[0 for i in range(50)]for j in range(50)]

for _ in range(input()):
    a=[]
    n,m=map(int,raw_input().split())
    
    for i in range(n):
        a.append(list(raw_input()))
   
    ok=1
    
    for i in range(n):
        for j in range(m):
            if a[i][j]=="B" and(( (j+1)<m and a[i][j+1]=="G") or ((i+1)<n and a[1+i][j]=="G")):
                ok=0;
            else:
                if (j+1)<m and a[i][j]=="B" and a[i][j+1]!="B":
                    a[i][j+1]="#"
                if (i+1)<n and a[i][j]=="B" and a[i+1][j]!="B":
                    a[i+1][j]="#"
        
    for i in range(n):
        for j in range(m):
            dp[i][j]=0
    
    
    if a[n-1][m-1]=="#":
        pass
    else:
        dp[n-1][m-1]=1
        crawl(n-1,m-1,a)
    
    for i in range(n):
        for j in range(m):
            if a[i][j]=="G" and dp[i][j]==0:
                ok=0;
        
    if ok:
        print "Yes"
    else:
        print "No"
    
    