import sys
from collections import deque, Counter
from itertools import product
#input = sys.stdin.buffer.readline

T = int(input())
for _ in range(T):
    n, m = map(int, input().split())
    bd = [list(input()) for _ in range(n)]
    gcc = 0
    for i, j in product(range(n), range(m)):
        if bd[i][j] == 'G': gcc += 1
        if bd[i][j] != 'B': continue
        for r, c in [(i-1,j), (i+1,j), (i,j-1), (i,j+1)]:
            if 0 <= r < n and 0 <= c < m and bd[r][c] == '.':
                bd[r][c] = '#'
    
    gc, bc = 0, 0
    vis = [[0]*m for _ in range(n)]
    q = deque([(n-1, m-1)]); vis[n-1][m-1] = 1
    while q:
        i, j = q.popleft()
        if bd[i][j] == 'G': gc += 1
        if bd[i][j] == 'B': bc += 1
        for r, c in [(i-1,j), (i+1,j), (i,j-1), (i,j+1)]:
            if (0 <= r < n and 0 <= c < m
                and bd[r][c] != '#' and bd[i][j] != '#'
                and not vis[r][c]):
                vis[r][c] = 1
                q.append((r, c))

    print("Yes" if gcc == gc and bc == 0 else "No")

