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 = [[ch for ch in ip()] for _ in range(n)]
    c=lambda x,y:x>=0 and x<n and y>=0 and y<m
    # print(a)
    blocked=set()
    ans=True
    isv=set()
    found=False
    for i in range(n):
        for j in range(m):
            if a[i][j]=='G':
                found=True
            if (i,j) in blocked or a[i][j]=='.' or a[i][j]=='#' or (i,j) in isv:
                continue
            if a[i][j]=='B':
                fl=False
                q=dq([(i,j)])
                while q:
                    x,y=q.popleft()
                    if x==n-1 and y==m-1:
                        fl=True
                        # print('bye',(x,y))
                        break
                    if (x,y) in blocked or a[x][y]=='#' :
                        continue
                    if a[x][y]=='G':
                        # print('hi',(x,y))
                        fl=True
                        break
                    if a[x][y]=='.':
                        blocked.add((x,y))
                        continue
                    isv.add((x,y))
                    for d,e in [[1,0],[0,1],[-1,0],[0,-1]]:
                        nx,ny=x+d,y+e
                        if c(nx,ny) and (nx,ny) not in isv:
                            a.append((nx,ny))
                if fl:
                    print((i,j))
                    ans=False
                    break
    # print(ans)
    if not found:
        print("yes")
        continue
    if not ans:
        print('no')
        continue
    can_reach=set()
    for i in range(n):
        for j in range(m):
            if a[i][j]=='G':
                if (i,j) in can_reach:
                    continue
                fl=False
                q=dq([(i,j)])
                isv=set()
                while q:
                    x,y=q.popleft()
                    if (x,y) in blocked or a[x][y]=='#':
                        continue
                    if x==n-1 and y==m-1 or ((x,y) in can_reach):
                        fl=True
                        break
                    isv.add((x,y))
                    for d,e in [[1,0],[0,1],[-1,0],[0,-1]]:
                        nx,ny=x+d,y+e
                        if (nx,ny) not in isv and c(nx,ny):
                            q.append((nx,ny))
                if not fl:
                    ans=False
                    break
                can_reach|=isv
    if ans:
        print('yes')
    else:
        print('no')