from collections import deque
t = int(input())
for _ in range(t):
    n, m = map(int, input().split())
    g = [["#"]*(m+2)]
    for i in range(n):
        g.append(["#"] + list(input()) + ["#"])
    g.append(["#"]*(m+2))

    for i in range(1, n+1):
        for j in range(1, m+1):
            if g[i][j] == "B":
                if g[i+1][j] != "G":
                    g[i+1][j] = "#"
                if g[i-1][j] != "G":
                    g[i-1][j] = "#"
                if g[i][j+1] != "G":
                    g[i][j+1] = "#"
                if g[i][j-1] != "G":
                    g[i][j-1] = "#"

    visit = [[False]*(m+2) for i in range(n+2)]
    visit[n][m] = True


    ans = "Yes"
    if g[n][m] == "#":
        f = 0
        for i in range(1, n+1):
            for j in range(1, m+1):
                if g[i][j] == "G":
                    f = 1
        if f == 1:
            ans = "No"

    q = deque([(n, m)])
    while q:
        x, y = q.popleft()
        for dx, dy in [(1, 0), (-1, 0), (0, -1), (0, 1)]:
            if g[x+dx][y+dy] != "#":
                if not visit[x+dx][y+dy]:
                    q.append((x+dx, y+dy))
                    visit[x+dx][y+dy] = True
    for i in range(1, n+1):
        for j in range(1, m+1):
            if g[i][j] == "G":
                if not visit[i][j]:
                    ans = "No"

    print(ans)
