def dfs(grid,x,y,n,m,visited):
    stack = [(x,y)]
    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] in ['G','.']:
                stack.append((x+1,y))

            if y+1 < m and grid[x][y+1] in ['G','.']:
                stack.append((x,y+1))

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

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

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] == 'G':
                        ans.append('No')
                        return

                    grid[i+1][j] = '#'

                if j+1 < m:
                    if grid[i][j+1] == 'G':
                        ans.append('No')
                        return

                    grid[i][j+1] = '#'

                if i-1 >= 0:
                    if grid[i-1][j] == 'G':
                        ans.append('No')
                        return

                    grid[i-1][j] = '#'

                if j-1 >= 0:
                    if grid[i][j-1] == 'G':
                        ans.append('No')
                        return

                    grid[i][j-1] = '#'

    good = 0
    for i in range(n):
        for j in range(m):
            if grid[i][j] == 'G':
                good += 1

    if good == 0:
        ans.append('Yes')
        return

    
    visited = set()
    found = False
    for i in range(n):
        for j in range(m):
            if grid[i][j] == 'G':
                dfs(grid,i,j,n,m,visited)
                found = True
                break

        if found:
            break

    if (n-1,m-1) not in visited:
        ans.append('No')
        return

    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

    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()
