def dfs(x,y):
    vis[x][y]=1
    for i in range(4):
        if x+dx[i]>=0 and x+dx[i]<n and y+dy[i]>=0 and y+dy[i]<m:
            if (g[x+dx[i]][y+dy[i]]=='.' or g[x+dx[i]][y+dy[i]]=='G')and vis[x+dx[i]][y+dy[i]]==0:
                dfs(x+dx[i],y+dy[i])


from collections import deque
for x in range(int(input())):
    n,m=list(map(int,input().split()))
    g=[]
    for i in range(n):
        g.append(list(input()))
    dx=[0,0,1,-1]
    dy=[1,-1,0,0]
    r=1
    c=0
    for x in range(n):
        for y in range(m):
            if g[x][y]=='B':
                for i in range(4):
                    if x+dx[i]>=0 and x+dx[i]<n and y+dy[i]>=0 and y+dy[i]<m:
                        if g[x+dx[i]][y+dy[i]]=='.':
                            g[x+dx[i]][y+dy[i]]='#'
                        elif g[x+dx[i]][y+dy[i]]=='G':
                            r=0
                            break
            
            elif g[x][y]=='G':
                c+=1
    if r==0:
        print('No')
    elif c>0 and g[n-1][m-1]=='#':
        print('No')
    else:
        r=1
        
        
        q=deque()
        vis=[[0 for j in range(m)]for i in range(n)] 
        dfs(n-1,m-1)
        
        
                    
                        
        for x in range(n):
            for y in range(m):
                if g[x][y]=='G' and vis[x][y]==0:
                    r=0
                    break
                    
        print('Yes' if r==1 else 'No')
                        
                                    
                            