import collections
import sys
input = sys.stdin.readline
from collections import defaultdict
def bfs(i,j):
    gcount=0
    bcount=0
    queue=collections.deque([(i,j)])
    visited[i][j]=1
    while queue:
        i,j=queue.popleft()
        for a,b in [(i+1,j),(i-1,j),(i,j+1),(i,j-1)]:
            if a==-1 or a==n or b==-1 or b==m or visited[a][b] or grid[a][b]=='#':
                continue
            if grid[a][b]=='G':
                gcount+=1
            if grid[a][b]=='B':
                bcount+=1
            visited[a][b]+=1
            queue.append((a,b))
    return(gcount,bcount)
t=int(input())
for i in range(t):
    grid=[]
    n,m=map(int,input().split())
    visited=[[0]*(m) for _ in range(n)]
    for j in range(n):
        row=[i for i in input() if i!='\n']
        grid.append(row)
    good_count=0
    #print(grid)
    for j in range(n):
        for k in range(m):
            #print(j,k)
            if grid[j][k]=='B':
                if 0<=(k+1) and (k+1)<m and grid[j][k+1]=='.':
                    grid[j][k+1]='#'
                if 0<=(k-1) and (k-1)<m and grid[j][k-1]=='.':
                    grid[j][k-1]='#'
                if 0<=(j+1) and (j+1)<n and grid[j+1][k]=='.':
                    grid[j+1][k]='#'
                if 0<=(j-1) and (j-1)<n and grid[j-1][k]=='.':
                    grid[j-1][k]='#'
            if grid[j][k]=='G':
                good_count+=1
    if grid[-1][-1]=='#' :
        if good_count==0:
            print('Yes')
        else:
            print('No')
        continue
    output,ans=bfs(n-1,m-1)
    if output==(good_count) and ans==0:
        print('Yes')
    else:
        print('No')
    
                    
    





































































    
    
    
    







 
