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

def bfs():
    q = deque([])
    dist = [[-1]*m for _ in range(n)]
    
    if S[n-1][m-1]!='#':
        q = deque([(n-1, m-1)])
        dist[n-1][m-1] = 0
        
    while q:
        cx, cy = q.popleft()
        
        for nx, ny in [(cx-1, cy), (cx+1, cy), (cx, cy-1), (cx, cy+1)]:
            if 0<=nx<n and 0<=ny<m and S[nx][ny]!='#' and dist[nx][ny]==-1:
                dist[nx][ny] = dist[cx][cy]+1
                q.append((nx, ny))
    
    return dist
                
t = int(input())

for _ in range(t):
    n, m = map(int, input().split())
    S = [list(input()[:-1]) for _ in range(n)]
    
    for i in range(n):
        for j in range(m):
            if S[i][j]=='B':
                for ni, nj in [(i-1, j), (i+1, j), (i, j-1), (i, j+1)]:
                    if 0<=ni<n and 0<=nj<m and S[ni][nj]=='.':
                        S[ni][nj] = '#'
                
    dist = bfs()
    ok = True
    ng = False
    
    for i in range(n):
        for j in range(m):
            if S[i][j]=='G' and dist[i][j]==-1:
                ok = False
            
            if S[i][j]=='B' and dist[i][j]!=-1:
                ng = True
    
    if ok and not ng:
        print('Yes')
    else:
        print('No')