from collections import deque
#from sys import stdin
#input = iter(stdin.readlines()).__next__

t = int(input())
for _ in range(t):
    n, m = map(int, input().split())
    maze = [['#'] * (m + 2)] + [['#'] + list(input().strip()) + ['#'] for _ in range(n)] + [['#'] * (m + 2)]

    def neighbours(r, c):
        yield r, c - 1
        yield r - 1, c
        yield r + 1, c
        yield r, c + 1

    good_guys = set()

    possible = True
    for r in range(1, n + 1):
        for c in range(1, m + 1):
            if maze[r][c] == 'B':
                for nr, nc in neighbours(r, c):
                    if maze[nr][nc] == 'G':
                        possible = False
                        break
                    elif maze[nr][nc] == '.':
                        maze[nr][nc] = '#'
            elif maze[r][c] == 'G':
                good_guys.add((r, c))
        #if not possible:
        #    break

    if len(good_guys) == 0:
        print("Yes")
        continue

    if maze[n][m] == '#':
        possible = False
    
    if possible:
        # bfs from maze[n][m]
        visited = set()
        visited.add((n, m))

        q = deque()
        q.append((n, m))

        while q:
            pr, pc = q.popleft()

            for nr, nc in filter(lambda n: n not in visited, neighbours(pr, pc)):
                if maze[nr][nc] in ['.', 'G']:
                    visited.add((nr, nc))
                    q.append((nr, nc))

        for good_guy in good_guys:
            if good_guy not in visited:
                print("No")
                break
        else:
            print("Yes")
    else:
        print("No")
