from collections import defaultdict
t = int(input())
for _ in range(t):
    n,m = map(int,input().strip().split())
    arr = []
    for _ in range(n):
        arr.append(list(input()))
    
    G = set()
    # Add extra walls
    f = 0
    for i in range(n):
        for j in range(m):
            if arr[i][j]=='G':
                G.add((i,j))
            elif arr[i][j]=='B':
                for x,y in [[i-1,j],[i+1,j],[i,j-1],[i,j+1]]:
                    if 0<=x<n and 0<=y<m and arr[x][y]!='B':
                        if arr[x][y]=='G':
                            f = 1
                            break
                        arr[x][y]='#'
    if f: print("No")
    elif arr[-1][-1]=='#':
        if G: print("No")
        else: print("Yes")
    else:
        visited = [[False for _ in range(m)] for _ in range(n)]
        visited[n-1][m-1] = True
        queue = [(n-1,m-1)]
        while queue:
            i,j = queue.pop()
            G.discard((i,j))
            for x,y in [[i-1,j],[i+1,j],[i,j-1],[i,j+1]]:
                    if 0<=x<n and 0<=y<m and not visited[x][y] and arr[x][y]!='#':
                        visited[x][y] = True
                        queue.append((x,y))
        if not G: print("Yes")
        else: print("No")
                        
                    
        
    
    
        
    
