def solve(n, m, maze):
    cnt = 0
    steps = [[0, 1], [1, 0], [-1, 0], [0, -1]]
    cross_border = lambda x, y, n, m: x < 0 or y < 0 or x >= n or y >= m
    # block bad people
    for i in range(n):
        for j in range(m):
            if maze[i][j] == 'G':
                cnt += 1
            if maze[i][j] != 'B':
                continue
            for si, sj in steps:
                x, y = i + si, j + sj
                if cross_border(x, y, n, m) or maze[x][y] == 'B':
                    continue
                if maze[x][y] == 'G':
                    return "No"
                maze[x][y] = '#'
    # check if good people can esc
    bfs = [(n-1, m-1)]
    visited = [[False] * m for _ in range(n)]
    while bfs:
        i, j = bfs[0]
        bfs.pop(0)
        if visited[i][j] or maze[i][j] == '#':
            continue
        visited[i][j] = True
        if maze[i][j] == 'G':
            cnt -= 1
        for si, sj in steps:
            x, y = i + si, j + sj
            if cross_border(x, y, n, m):
                continue
            bfs.append((x, y))
    if cnt:
        return "No"
    return "Yes"


def main():
    inp = lambda: [int(x) for x in input().split()]
    inn = lambda: int(input())
    t = inn()
    for _ in range(t):
        n, m = inp()
        maze = []
        for _ in range(n):
            maze.append(list(input()))
        print(solve(n, m, maze))


if __name__ == '__main__':
    main()
