from collections import deque


def test_case() -> bool:
    n, m = map(int, input().split())
    grid = list()
    for i in range(n):
        grid.append(list(input()))

    valid = lambda r, c: r >= 0 and r < n and c >= 0 and c < m

    num_good = 0
    directions = ((-1, 0), (1, 0), (0, -1), (0, 1))
    # block off all the bad guys
    for r in range(n):
        for c in range(m):
            if grid[r][c] == "B":
                for dr, dc in directions:
                    x, y = r + dr, c + dc
                    if not valid(x, y):
                        continue
                    if grid[x][y] == "G":
                        return False
                    if grid[x][y] == ".":
                        grid[x][y] = "#"
            elif grid[r][c] == "G":
                num_good += 1
    if num_good == 0:
        return True
    if grid[-1][-1] == "#":
        return False
    # run bfs to see if any good people are blocked off
    q = deque()
    visited = set()
    q.append((n - 1, m - 1))
    visited.add((n - 1, m - 1))
    while q:
        r, c = q.popleft()
        if grid[r][c] == "G":
            num_good -= 1
        for dr, dc in directions:
            x, y = r + dr, c + dc
            if not valid(x, y) or (x, y) in visited:
                continue
            if grid[x][y] != "#":
                q.append((x, y))
                visited.add((x, y))
    return num_good == 0


if __name__ == "__main__":
    t = int(input())
    for _ in range(t):
        res = test_case()
        print("yes" if res else "no")

