import sys
from itertools import product

t = int(sys.stdin.readline())

def adj(i,j,n,m):
    if i-1!= -1:
        yield (i-1,j)
    if i+1!= n:
        yield (i+1,j)
    if j-1!= -1:
        yield (i,j-1)
    if j+1!= m:
        yield (i,j+1)

def floodfill(maze, x0,y0, n,m):
    if maze[x0][y0] == '#':
        return
    maze[x0][y0] = '#'
    for i,j in adj(x0,y0,n,m):
        floodfill(maze,i,j,n,m)

for _ in range(t):
    n,m = [int(i) for i in sys.stdin.readline().split()]
    maze = []
    for _  in range(n):
        maze = maze + [[c for c in sys.stdin.readline().rstrip()]]
    pos = True
    for x,y in product(range(n), range(m)):
        if maze[x][y] == 'B':
            maze[x][y] = '#'
            for i,j in adj(x,y,n,m):
                if maze[i][j] == 'G':
                    pos = False
                if maze[i][j] != 'B':
                    maze[i][j] = '#'
    if not pos:
        print("No")
        continue
    floodfill(maze,n-1,m-1,n,m)
    pos = True
    for row in maze:
        for cell in row:
            if cell=='G':
                pos=False
    if pos:
        print("Yes")
    else:
        print("No")



