
import collections
import heapq


def read():
    return input().strip()


def readInt():
    return int(input().strip())


def readList():
    return list(map(int, input().strip().split()))


def solve(n, m, grid):
    # Block neighbouring cells of B
    for x in range(n):
        for y in range(m):
            if grid[x][y] == "B":
                for delX, delY in [(-1, 0), (1, 0), (0, 1), (0, -1)]:
                    newX, newY = x+delX, y+delY

                    if 0 <= newX < n and 0 <= newY < m and grid[newX][newY] == ".":
                        grid[newX][newY] = "#"

    # BFS from end cell
    queue = collections.deque([])

    visited = set()

    if grid[n-1][m-1] == ".":
        queue.append((n-1, m-1))
        visited.add((n-1, m-1))

    while queue:
        x, y = queue.popleft()

        for delX, delY in [(-1, 0), (1, 0), (0, 1), (0, -1)]:
            newX, newY = x+delX, y+delY

            if 0 <= newX < n and 0 <= newY < m and grid[newX][newY] != "#" and (newX, newY) not in visited:
                visited.add((newX, newY))
                queue.append((newX, newY))

    for x in range(n):
        for y in range(m):
            if (grid[x][y] == "G" and (x, y) not in visited) or (grid[x][y] == "B" and (x, y) in visited):
                return False

    return True


t = readInt()
# [n,m] = readList()

for i in range(t):
    [n, m] = readList()
    grid = []

    for _ in range(n):
        grid.append([ch for ch in read()])

    print("Yes" if solve(n, m, grid) else "No")
