import sys

int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]
dij=[(1,0),(0,1),(-1,0),(0,-1)]

def main():
    for _ in range(II()):
        h,w=MI()
        tt=[list(SI()) for _ in range(h)]
        ng=False
        cntG=0
        for i in range(h):
            for j in range(w):
                if tt[i][j]=="G":cntG+=1
                if tt[i][j]=="B":
                    for di,dj in dij:
                        ni,nj=i+di,j+dj
                        if ni<0 or nj<0 or ni>=h or nj>=w:continue
                        if tt[ni][nj] == "B":continue
                        if tt[ni][nj]=="G":
                            ng=True
                            continue
                        tt[ni][nj]="#"
        #p2D(tt)

        if cntG==0:
            print("Yes")
            continue
        if ng or tt[h-1][w-1]=="#":
            print("No")
            continue

        stack=[(h-1,w-1)]
        tt[h-1][w-1]="#"
        while stack:
            i,j=stack.pop()
            for di, dj in dij:
                ni, nj = i + di, j + dj
                if ni < 0 or nj < 0 or ni >= h or nj >= w: continue
                if tt[ni][nj] == "#":continue
                if tt[ni][nj] == "G":cntG-=1
                tt[ni][nj]="#"
                stack.append((ni,nj))
        if cntG==0:print("Yes")
        else:print("No")

main()