from collections import defaultdict
def dfs(arr,i,j,n,m,memo,visited):
    if i==n-1 and j==m-1:
        return 1
    if i<0 or i>=n or j<0 or j>=m:
        return 0
    if arr[i][j]=='#': return 0
    if memo[i][j]!=-1: return memo[i][j]
    if visited[i][j]!=-1: return 0
    visited[i][j] = 1
    ans = 0
    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]!='#':
            ans = dfs(arr,x,y,n,m,memo,visited)
            memo[x][y] = ans
        if ans: break
    memo[i][j] = ans
    return ans
    
    
t = int(input())
for _ in range(t):
    n,m = map(int,input().strip().split())
    arr = []
    for _ in range(n):
        arr.append(list(input()))
        
    # Add extra walls
    f = 0
    for i in range(n):
        for j in range(m):
            if 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: break
        if f: break
    if f: print("No")
    else:
        f = 0
        memo = [[-1 for _ in range(m)] for _ in range(n)]
        visited = [[-1 for _ in range(m)] for _ in range(n)]
        for i in range(n):
            for j in range(m):
                if arr[i][j]=='G':
                    if not dfs(arr,i,j,n,m,memo,visited):
                        f = 1
                        break
            if f: break
        if f: print("No")
        else: print("Yes")
                        
                    
        
    
    
        
    
