import collections
t = int(input())

def is_free(grid, vis, i, j):
    if (i, j) in vis:
        return False
    n = len(grid)
    m = len(grid[0])
    if i < 0 or i >= n or j < 0 or j >= m:
        return False
    if grid[i][j] in ('#', 'B'):
        return False
    for ii, jj in ((i - 1, j), (i, j - 1), (i, j + 1), (i + 1, j)):
        if ii >= 0 and ii < n and jj >= 0 and jj < m and grid[ii][jj] == 'B':
            return False
    return True


for _ in range(t):
    n, m = map(int, input().split())
    grid = [list(input()) for _ in range(n)]
    cnt = 0
    for row in grid:
        for cell in row:
            if cell == 'G':
                cnt += 1

    q = collections.deque([])
    vis = set()
    if is_free(grid, vis, n - 1, m - 1):
        q.append((n - 1, m - 1))
    while q:
        i, j = q.popleft()
        for ii, jj in ((i - 1, j), (i, j - 1), (i, j + 1), (i + 1, j)):
            if is_free(grid, vis, ii, jj):
                if grid[ii][jj] == 'G':
                    cnt -= 1
                vis.add((ii, jj))
                q.append((ii, jj))

    print("Yes" if cnt == 0 else "No")

