from collections import deque

grid = []
n, m = 0, 0
dx = [1, -1, 0, 0]
dy = [0, 0, 1, -1]
vis = []


def data_input():
    global grid, n, m
    n, m = map(int, input().split())
    grid = [["#" for _ in range(m + 5)] for __ in range(n + 5)]
    for i in range(1, n + 1):
        grid[i] = ["#"] + list(input()) + ["#"]


def check_adj():
    for i in range(1, n + 1):
        for j in range(1, m + 1):
            if grid[i][j] == "B":
                for k in range(4):
                    if grid[i + dx[k]][j + dy[k]] == "G":
                        return True
    return False


def surround():
    global grid
    for i in range(1, n + 1):
        for j in range(1, m + 1):
            if grid[i][j] == "B":
                for k in range(4):
                    if grid[i + dx[k]][j + dy[k]] == ".":
                        grid[i + dx[k]][j + dy[k]] = "#"


def bfs():
    global vis
    vis = [[0 for _ in range(m + 5)] for __ in range(n + 5)]
    q = deque()
    if grid[n][m] != "#":
        q.append((n, m))
        vis[n][m] = 1
    while q:
        now = q.popleft()
        for k in range(4):
            n_x = now[0] + dx[k]
            n_y = now[1] + dy[k]
            if grid[n_x][n_y] != "#" and not vis[n_x][n_y]:
                vis[n_x][n_y] = 1
                q.append((n_x, n_y))


def check():
    for i in range(1, n + 1):
        for j in range(1, m + 1):
            if grid[i][j] == "G" and not vis[i][j]:
                return False
    return True


def solve():
    data_input()
    if check_adj():
        print("No")
        return
    surround()
    bfs()
    print(["No", "Yes"][check()])


t = int(input())
for _ in range(t):
    solve()
