import sys
from collections import deque

readline = sys.stdin.readline

ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))

def solve():
    h, w = nm()
    g = [list(ns()) for _ in range(h)]
    d = [(1, 0), (0, 1), (-1, 0), (0, -1)]
    for i in range(h):
        for j in range(w):
            if g[i][j] == 'B':
                for di, dj in d:
                    ni = i + di; nj = j + dj
                    if 0 <= ni < h and 0 <= nj < w and g[ni][nj] == '.':
                        g[ni][nj] = '#'
    q = deque()
    f = [[-1]*w for _ in range(h)]
    if g[-1][-1] == '.':
        f[-1][-1] = 0
        q.append((h-1, w-1))
    while q:
        i, j = q.popleft()
        for di, dj in d:
            ni = i + di; nj = j + dj
            if 0 <= ni < h and 0 <= nj < w and g[ni][nj] != '#' and f[ni][nj] < 0:
                f[ni][nj] = f[i][j] + 1
                q.append((ni, nj))
    for i in range(h):
        for j in range(w):
            if g[i][j] == 'G' and f[i][j] < 0 or g[i][j] == 'B' and f[i][j] >= 0:
                print('No')
                return
    print('Yes')
    return

# solve()

T = int(input())
for _ in range(T):
    solve()
