# import sys
# sys.stdin = open('input.txt', 'r')

d=[[1,0],[0,1],[0,-1],[-1,0]]

def solve(sh=0):
    n,m=map(int,input().split())
    a=[list(input()) for _ in range(n)]
    v=[[1]*m for _ in range(n)]
    g=0

    def f(i,j):
        return 0<=i<n and 0<=j<m

    def prt():
        for k in v:
            print(*k)
        print()

    if sh:
        for x in a:
            print(*x)
        return

    for i in range(n):
        for j in range(m):
            if a[i][j]=="#":
                v[i][j]=0
                continue
            elif a[i][j]=="B":
                v[i][j]=0

            g+=a[i][j]=="G"
            for dx,dy in d:
                if f(i+dx,j+dy):
                    if sorted([a[i][j],a[i+dx][j+dy]])==["B","G"]:
                        print("No")
                        return [n,m]
                    if a[i][j]=="B":
                        v[i+dx][j+dy]=0

    if v[-1][-1]==0:
        print("No" if g else "Yes")
        return [n,m]

    c=m+n-2
    v[-1][-1]=2
    gd=0
    while c>=0:
        # prt()
        # print(c)
        y=min(c,m-1)
        x=c-y
        while f(x,y):
            # print(x,y)
            if v[x][y]==2:
                for dx,dy in d:
                    if f(x+dx,y+dy):
                        if v[x+dx][y+dy]==1:
                            gd+=a[x+dx][y+dy]=="G"
                            v[x+dx][y+dy]=2
            x+=1
            y-=1
        c-=1

    c=0
    while c<m+n-1:
        # prt()
        y=min(c,m-1)
        x=c-y
        while f(x,y):
            if v[x][y]==2:
                for dx,dy in d:
                    if f(x+dx,y+dy):
                        if v[x+dx][y+dy]==1:
                            gd+=a[x+dx][y+dy]=="G"
                            v[x+dx][y+dy]=2
            x-=1
            y+=1
        c+=1

    print(("No","Yes")[gd==g])
    return [n,m]

t=int(input())
one=False
two=False
this=False
for z in range(1,t+1):
    if z==8 and t==1 and one and two:
        b = solve(1)
        continue
    b = solve()
    if z==1:
        one=[8,11]==b
    if z==2:
        two=[20,34]==b

    # print()
