from sys import stdin

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] = '#'

    visited = set()

    q = [(n-1,m-1)]

    while q:
        x,y = q.pop()

        if not (x,y) in visited:
            visited.add((x,y))
            if x > 0:
                if grid[x-1][y] != '#':
                    q.append((x-1,y))
            if x < n-1:
                if grid[x+1][y] != '#':
                    q.append((x+1,y))
            if y > 0:
                if grid[x][y-1] != '#':
                    q.append((x,y-1))
            if y < m-1:
                if grid[x][y+1] != '#':
                    q.append((x,y+1))
                    
    for x in range(n):
        if valid:
            for y in range(m):
                if grid[x][y] == 'G' and (x,y) not in visited:
                    valid = False
                    break
    
    if not valid:
        print('No')
    else:
        print('Yes')
    
