def solve(grid,n,m,ans):
    for i in range(n):
        for j in range(m):
            if grid[i][j] == 'B':
                if i+1 < n:
                    if grid[i+1][j] == '.':
                        grid[i+1][j] = '#'

                if j+1 < m:
                    if grid[i][j+1] == '.':
                        grid[i][j+1] = '#'

                if i-1 >= 0:
                    if grid[i-1][j] == '.':
                        grid[i-1][j] = '#'

                if j-1 >= 0:
                    if grid[i][j-1] == '.':
                        grid[i][j-1] = '#'

    if grid[n-1][m-1] == '.':
        stack = [(n-1,m-1)]
    else:
        stack = []
        
    visited = set()
    while stack:
        x,y = stack.pop()
        if (x,y) not in visited:
            visited.add((x,y))
            if x+1 < n and grid[x+1][y] != '#':
                stack.append((x+1,y))

            if y+1 < m and grid[x][y+1] != '#':
                stack.append((x,y+1))

            if x-1 >= 0 and grid[x-1][y] != '#':
                stack.append((x-1,y))

            if y-1 >= 0 and grid[x][y-1] != '#':
                stack.append((x,y-1))

    for i in range(n):
        for j in range(m):
            if grid[i][j] == 'G' and (i,j) not in visited:
                ans.append('No')
                return
            if grid[i][j] == 'B' and (i,j) in visited:
                ans.append('No')
                return

    ans.append('Yes')
                

def main():
    t = int(input())
    ans = []
    for i in range(t):
        n,m = map(int,input().split())
        grid = []
        for j in range(n):
            grid.append(list(input()))

        solve(grid,n,m,ans)

    for i in ans:
        print(i)


main()
