import sys
sys.setrecursionlimit(10**5)
for _ in range(int(input())):
    n, m = map(int, input().split())
    grid = [list(input()) for _ in range(n)]
    for i in range(n):
        for j in range(m):
            if grid[i][j] == 'B':
                if i > 0 and grid[i - 1][j] == '.':
                    grid[i - 1][j] = '#'
                if i < n - 1 and grid[i + 1][j] == '.':
                    grid[i + 1][j] = '#'
                if j > 0 and grid[i][j - 1] == '.':
                    grid[i][j - 1] = '#'
                if j < m - 1 and grid[i][j + 1] == '.':
                    grid[i][j + 1] = '#'
    access = [[False] * m for _ in range(n)]
    def dfs(i, j):
        if 0 <= i < n and 0 <= j < m and grid[i][j] != '#':
            if access[i][j]:
                return
            access[i][j] = True
            dfs(i - 1, j)
            dfs(i, j - 1)
            dfs(i + 1, j)
            dfs(i, j + 1)
    dfs(n - 1, m - 1)
    ans = "Yes"
    for i in range(n):
        for j in range(m):
            if grid[i][j] == 'G':
                if not access[i][j]:
                    ans = "No"
            if grid[i][j] == 'B':
                if access[i][j]:
                    ans = "No"
    print(ans)