import sys
ip=lambda :sys.stdin.readline().rstrip()
from collections import deque as dq
def f(src,isv):
    goods=dq([src])
    fl=False
    while goods:
        x,y=goods.popleft()
        if isv[x][y]:
            continue
        if x==n-1 and y==m-1:
            fl=True
            continue
        isv[x][y]=True
        for d,e in [[1,0],[0,1],[-1,0],[0,-1]]:
            nx,ny=x+d,y+e
            tp=[nx,ny]
            if c(nx,ny) and not isv[nx][ny]:
                if not blocked[nx][ny] and a[nx][ny]!='#':
                    goods.append(tp)
    return fl
for _ in range(int(ip())):
    n,m=map(int,ip().split())
    a = [list(ip()) for _ in range(n)]
    c=lambda x,y:x>=0 and x<n and y>=0 and y<m
    blocked=[[False for _ in range(m)] for _ in range(n)]
    ans,found=True,False
    isv=[[False for _ in range(m)] for _ in range(n)]
    bads,goods=dq(),dq()
    for i in range(n):
        for j in range(m):
            if a[i][j]=='B':
                bads.append([i,j])
            if a[i][j]=='G':
                found=True
                goods.append([i,j])
    if not found:
        print("yes")
        continue
    fl=False
    # print(bads)
    while bads:
        x,y=bads.popleft()
        # print(x,y)
        if x==n-1 and y==m-1:
            fl=True
            break
        isv[x][y]=True
        if blocked[x][y] or a[x][y]=='#':
            continue
        if a[x][y]=='G':
            fl=True
            break
        if a[x][y]=='.':
            blocked[x][y]=True
            continue
        for d,e in [[1,0],[0,1],[-1,0],[0,-1]]:
            nx,ny=x+d,y+e
            tp=[nx,ny]
            if c(nx,ny) and not isv[nx][ny]:
                bads.append(tp)
    if fl:
        print('no')
        continue
    ans=True
    for i in goods:
        if not isv[i[0]][i[1]]:
            if not f(i,isv):
                ans=False
                break
    print('yes' if ans else 'no')