from sys import stdin, exit, setrecursionlimit
from collections import deque

input = stdin.readline
lmi = lambda: list(map(int, input().split()))
mi = lambda: map(int, input().split())
si = lambda: input().strip('\n')
ssi = lambda: input().strip('\n').split()


def bfs(y, x):
    q = deque([(y, x)])
    while q:
        y, x = q.popleft()
        if grid[y][x] == "G":
            global yes
            yes = True
        if grid[y][x] == "B":
            global no
            no = True
        if y == n - 1 and x == m - 1:
            global bot
            bot = True
        for a, b in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
            if n > y + a >= 0 and m > x + b >= 0 and not vis[y + a][x + b] and grid[y + a][x + b] != "#":
                q.append((a + y, x + b))
                vis[a + y][x + b] = True


for _ in range(int(input())):
    n, m = mi()
    grid = [list(si()) for i in range(n)]
    vis = [[False for i in range(m)] for j in range(n)]
    bad = False
    for i in range(n):
        for j in range(m):
            if grid[i][j] == "B":
                for a, b in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
                    if n > i + a >= 0 and m > j + b >= 0:
                        if grid[i + a][j + b] == "G":
                            bad = True
                        if grid[i + a][j + b] == "B":
                            continue
                        grid[i + a][j + b] = "#"
    for i in range(n):
        for j in range(m):
            yes = False
            no = False
            bot = False
            if not vis[i][j] and grid[i][j] != "#":
                bfs(i, j)
            if not bot and yes:
                bad = True
            if bot and no:
                bad = True
    print("No" if bad else "Yes")