from collections import deque

def solve(n, m, mp):
    ngood = 0
    for r in range(n):
        for c in range(m):
            if mp[r][c] == 'B':
                for dr, dc in [(-1, 0), (1, 0), (0, -1), (0, 1)]:
                    nr, nc = r+dr, c+dc
                    if 0 <= nr < n and 0 <= nc < m:
                        if mp[nr][nc] == '.':
                            mp[nr][nc] = '#'
                        elif mp[nr][nc] == 'G':
                            return False
            elif mp[r][c] == 'G':
                ngood += 1
    # for row in mp:
    #     print(row)
    q = deque()
    seen = set()
    if mp[n-1][m-1] != '#':
        q.append((n-1, m-1))
        seen.add((n-1, m-1))
    while q:
        r, c = q.popleft()
        if mp[r][c] == 'G':
            ngood -= 1
        for dr, dc in [(-1, 0), (1, 0), (0, -1), (0, 1)]:
            nr, nc = r+dr, c+dc
            if 0 <= nr < n and 0 <= nc < m and mp[nr][nc] in '.G' and (nr, nc) not in seen:
                seen.add((nr, nc))
                q.append((nr, nc))
    return ngood == 0

t = int(input())
for _ in range(t):
    n, m = map(int, input().split())
    mp = []
    for _ in range(n):
        mp.append(list(input()))
    print('Yes' if solve(n, m, mp) else 'No')