from collections import deque


def solve(maze, n, m):
    def _valid(i, j):
        return i >= 1 and i <= n and j >= 1 and j <= m

    directions = ((1,0), (0,1), (-1,0), (0,-1))
    for row in range(1, n + 1):
        for col in range(1, m + 1):
            if maze[row][col] == 'B':
                # explore neighbours
                for d in directions:
                    ni = row + d[0]
                    nj = col + d[1]
                    if _valid(ni, nj) and maze[ni][nj] == '.':
                        # block this side
                        maze[ni][nj] = '#'

    # visit all cells
    queue = deque()
    visited = set()
    if maze[n][m] == '.':
        cell = (n, m)
        queue.appendleft(cell)
        visited.add(cell)
    while queue:
        cell = queue.pop()
        for d in directions:
            ni = cell[0] + d[0]
            nj = cell[1] + d[1]
            if _valid(ni, nj) and maze[ni][nj] != '#':
                neighbour = (ni, nj)
                if neighbour not in visited:
                    queue.appendleft(neighbour)
                    visited.add(neighbour)

    for row in range(1, n + 1):
        for col in range(1, m + 1):
            if maze[row][col] == 'G' and (row, col) not in visited:
                return False
            if maze[row][col] == 'B' and (row, col) in visited:
                return False

    return True


def solve_for_input():
    n, m = map(int, input().split())
    maze = [['#' for _ in range(m+2)] for _ in range(n+2)]
    for i in range(1, n+1):
        maze[i][1:m] = list(input())
    return solve(maze, n, m)


if __name__ == "__main__":
    tc = int(input())
    while tc > 0:
        print("Yes" if solve_for_input() else "No")
        tc -= 1
