import sys

sys.setrecursionlimit(100000)

DIR = [(-1, 0), (1, 0), (0, -1), (0, 1)]

def dfs(i, j):
    if i > n or i == 0 or j > m or j == 0:
        return
    used[i][j] = 1
    for di, dj in DIR:
        if not used[i + di][j + dj] and a[i + di][j + dj] != "#":
            dfs(i + di, j + dj)
            

for t in range(int(input())):
    n, m = list(map(int, input().split()))
    a = [["#"] * (m + 2)] + [list("#" + input() + "#") for i in range(n)] + [["#"] * (m + 2)]
    used = [[0] * (m + 2) for i in range(n + 2)]
    ok = True
    for i in range(1, n + 1):
        for j in range(1, m + 1):
            if a[i][j] == "B":
                for di, dj in DIR:
                    if a[i + di][j + dj] == "G":
                        ok = False
                    elif a[i + di][j + dj] != "B":
                        a[i + di][j + dj] = "#"
    if a[n][m] != "#":
        dfs(n, m)
    for i in range(1, n + 1):
        for j in range(1, m + 1):
            if a[i][j] == "G" and not used[i][j]:
                ok = False
    print("Yes" if ok else "No")