from collections import deque
t = int(input())
for _ in range(t):
    n,m = map(int, input().split())
    L = [list(input()) for _ in range(n)]

    for i in range(n):
        L[i] = ["#"] + L[i] + ["#"]
    L.insert(0, ["#"]*(m+2))
    L.append(["#"]*(m+2))

    ans = "Yes"
    G = []
    for i in range(1, n+1):
        for j in range(1, m+1):
            if L[i][j] == "G":
                G.append((i, j))
    for i in range(1, n+1):
        for j in range(1, m+1):
            if L[i][j] == "B":
                L[i-1][j] = "#"
                if L[i+1][j] != "B":
                    L[i+1][j] = "#"
                L[i][j-1] = "#"
                if L[i][j+1] != "B":
                    L[i][j+1] = "#"

    q = deque()
    q.append((n, m))
    used = [[0]*(m+2) for _ in range(n+2)]
    used[n][m] = 1
    while L[n][m] != "#" and q:
        temp = q.pop()
        i = temp[0]
        j = temp[1]
        if L[i-1][j] != "#" and used[i-1][j] == 0:
            used[i-1][j] = 1
            q.append((i-1, j))
        if L[i+1][j] != "#" and used[i+1][j] == 0:
            used[i+1][j] = 1
            q.append((i+1, j))
        if L[i][j-1] != "#" and used[i][j-1] == 0:
            used[i][j-1] = 1
            q.append((i, j-1))
        if L[i][j+1] != "#" and used[i][j+1] == 0:
            used[i][j+1] = 1
            q.append((i, j+1))

    for g in G:
        if used[g[0]][g[1]] == 0:
            ans = "No"
            break
    print(ans)
