import sys
ip=lambda :sys.stdin.readline().rstrip()
from collections import deque as dq
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=set()
    ans,found=True,False
    isv=set()
    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
    while bads:
        tp1=bads.popleft()
        x,y=tp1[0],tp1[1]
        if x==n-1 and y==m-1:
            fl=True
            break
        isv.add(tp1)
        if (x,y) in blocked or a[x][y]=='#':
            continue
        if a[x][y]=='G':
            fl=True
            break
        if a[x][y]=='.':
            blocked.add(tp1)
            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 tp not in isv:
                bads.append(tp)
    if fl:
        print('no')
        continue
    can_reach=set()
    fl=False
    isv=set()
    while goods:
        tp1=goods.popleft()
        x,y=tp1[0],tp1[1]
        isv.add(tp1)
        if x==n-1 and y==m-1 or (tp1 in can_reach):
            fl=True
            if goods:
                fl=False
                can_reach|=isv
                isv=set()
            continue
        for d,e in [[1,0],[0,1],[-1,0],[0,-1]]:
            nx,ny=x+d,y+e
            tp=(nx,ny)
            if tp not in isv and c(nx,ny):
                if tp not in blocked and a[nx][ny]!='#':
                    goods.append(tp)
    if not fl:
        print('no')
        continue
    print('yes')