from collections import defaultdict as dd,deque as dq
import sys
input=sys.stdin.readline
t=int(input())
def bfs(ll,i,n,m):
    x,y=i
    for X,Y in [(x+1,y),(x,y+1),(x-1,y),(x,y-1)]:
        if(X<n and Y<m and X>=0 and Y>=0):
            if(ll[X][Y]=='.'):
                ll[X][Y]='#'
    '''
    while q:
        a,st=q.pop()
        vis[a]=1
        if(a==(n-1,m-1)):
            #print(st)
            ll[st[0]][st[1]]='#'
            continue
        x,y=a
                if(vis[(X,Y)]==0):
                    #print(X,Y,st)
                    if(ll[X][Y]=='.'):
                        if(st==(-1,-1)):
                            cst=(X,Y)
                            q.appendleft(((X,Y),cst))
                        else:
                            q.appendleft(((X,Y),st))
                    elif(ll[X][Y]=='G'):
                        #print(st)
                        if(st!=(-1,-1)):
                            ll[st[0]][st[1]]='#'
     '''
   
def gbfs(ll,i,vis,n,m):
    q=dq([i])
    vis[i]=1
    lol=0
    while q:
        a=q.pop()
        x,y=a
        if((x,y)==(n-1,m-1)):
            lol=1
        for X,Y in [(x+1,y),(x,y+1),(x-1,y),(x,y-1)]:
            if(X<n and Y<m and X>=0 and Y>=0):
                #print(X,Y)
                if(vis[(X,Y)]==0):
                    if(ll[X][Y]=='.' or ll[X][Y]=='G'):
                        q.appendleft((X,Y))
                    elif(ll[X][Y]=='B'):
                        return False
                    elif(ll[X][Y]=='TG'):
                        return True
                    vis[(X,Y)]=1
                    
    if(lol):
        return True
    return False
              
while t:
    n,m=map(int,input().split())
    bb=[]
    gb=[]
    ll=[]
    lol=0
    for i in range(n):
        s=list(input().split()[0].strip())
        
        ll.append(s)
        for j in range(m):
            if(ll[i][j]=='B'):
                bb.append((i,j))
            if(ll[i][j]=='G'):
                gb.append((i,j))
    for i in bb:
        bfs(ll,i,n,m)
    '''
    for i in ll:
        print(i)
    '''
    
    for i in gb:
        vis=dd(int)
        if( not gbfs(ll,i,vis,n,m)):
            lol=1
            break
        else:
            ll[i[0]][i[1]]='TG'
    if(lol):
        print("No")
    else:
        print("Yes")
    t-=1
            

    