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

    gs = []
    ok = True
    for i in range(1, n+1):
        for j in range(1, m+1):
            if mz[i][j] == "B":
                for dy, dx in [[-1, 0], [1, 0], [0, -1], [0, 1]]:
                    y, x = i+dy, j+dx
                    if y == n and x == m:
                        ok = False
                        break
                    if mz[y][x] == ".":
                        mz[y][x] = "#"
            elif mz[i][j] == "G":
                gs.append([i, j])

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

    if not ok:
        print("No")
        continue

    ans = 0
    for sy, sx in gs:
        ok = False
        visited = {}
        q = deque()
        q.append([sy, sx])
        while len(q) > 0:
            y, x = q.popleft()
            if y == n and x == m:
                ok = True
                break
            for dy, dx in [[-1, 0], [1, 0], [0, -1], [0, 1]]:
                ny, nx = y+dy, x+dx
                if (ny, nx) not in visited and mz[ny][nx] != "#":
                    visited[(ny, nx)] = True
                    q.append([ny, nx])
        if ok:
            ans += 1

    print("Yes" if ans == len(gs) else "No")
