import sys
input=sys.stdin.readline
from collections import deque

def solve(n,m,A):
    Map=[['.']*m for _ in range(n)]
    Gs=[]
    Bs=[]
    for i,a in enumerate(A):
        for j,s in enumerate(a):
            if s=='#':
                Map[i][j]='#'
            elif s=='G':
                Gs.append((i,j))
            elif s=='B':
                Bs.append((i,j))
                Map[i][j]='#'
    if len(Gs)==0:
        return 'Yes'
    D=[(1,0),(-1,0),(0,1),(0,-1)]
    for x,y in Bs:
        for dx,dy in D:
            to_x,to_y=x+dx,y+dy
            if to_x<0 or to_x>=n or to_y<0 or to_y>=m:
                continue
            Map[to_x][to_y]='#'
    if Map[n-1][m-1]=='#':
        return 'No'
    q=deque()
    q.append((n-1,m-1))
    Visited=[[0]*m for _ in range(n)]
    Visited[n-1][m-1]=1
    while q:
        x,y=q.popleft()
        for dx,dy in D:
            to_x,to_y=x+dx,y+dy
            if to_x<0 or to_x>=n or to_y<0 or to_y>=m:
                continue
            if Map[to_x][to_y]=='.' and Visited[to_x][to_y]==0:
                q.append((to_x,to_y))
                Visited[to_x][to_y]=1
    for x,y in Gs:
        if Visited[x][y]==0:
            return 'No'
    return 'Yes'

def main():
    t=int(input())
    for _ in range(t):
        n,m=map(int,input().split())
        A=[list(input().strip()) for _ in range(n)]
        #print(A)
        ans=solve(n,m,A)
        sys.stdout.write(ans+'\n')
    
if __name__=='__main__':
    main()