from sys import stdin

def reaches(grid,x,y,mem,q):
    
    n = len(grid)
    m = len(grid[0])

    if (x,y) in q:
        return False

    if grid[x][y] == '#':
        return False

    if mem[x][y] != -1:
        return mem[x][y]

    q.add((x,y))

    if x > 0:
        if reaches(grid,x-1,y,mem,q):
            mem[x][y] = True
            q.remove((x,y))
            return True
    if x < n-1:
        if reaches(grid,x+1,y,mem,q):
            mem[x][y] = True
            q.remove((x,y))
            return True
    if y > 0:
        if reaches(grid,x,y-1,mem,q):
            mem[x][y] = True
            q.remove((x,y))
            return True
    if y < m-1:
        if reaches(grid,x,y+1,mem,q):
            mem[x][y] = True
            q.remove((x,y))
            return True
    q.remove((x,y))
    mem[x][y] = False
    return False

for case in range(int(stdin.readline())):
    n,m = [int(x) for x in stdin.readline().split()]

    grid = []

    for x in range(n):
        grid.append(list(stdin.readline().strip()))

    valid = True

    for x in range(n):
        if valid:
            for y in range(m):
                if grid[x][y] == 'B':
                    if x > 0:
                        if grid[x-1][y] == 'G':
                            valid = False
                            break
                        if grid[x-1][y] != 'B':
                            grid[x-1][y] = '#'
                    if x < n-1:
                        if grid[x+1][y] == 'G':
                            valid = False
                            break
                        if grid[x+1][y] != 'B':
                            grid[x+1][y] = '#'
                    if y > 0:
                        if grid[x][y-1] == 'G':
                            valid = False
                            break
                        if grid[x][y-1] != 'B':
                            grid[x][y-1] = '#'
                    if y < m-1:
                        if grid[x][y+1] == 'G':
                            valid = False
                            break
                        if grid[x][y+1] != 'B':
                            grid[x][y+1] = '#'
                    grid[x][y] = '#'
    mem = [[-1 for a in range(m)] for b in range(n)]
    mem[-1][-1] = True
    q = set()

    for x in range(n):
        if valid:
            for y in range(m):
                if grid[x][y] == 'G':
                    if not reaches(grid, x,y,mem,q):
                        valid = False
                        break
    if not valid:
        print('No')
    else:
        print('Yes')
    
