def modify(l):
    for i in range(n):
        for j in range(m):
            if(l[i][j]=='B'):
                dx=[-1,0,0,1]
                dy=[0,-1,1,0]
                for k in range(4):
                    for po in range(4):
                        X=i+dx[k]
                        Y=j+dy[po]
                        if(X<0 or X>=n):
                            continue
                        if(Y<0 or Y>=m):
                            continue
                        if(l[X][Y]=='G'):
                            return 0
                        if(l[X][Y]=='.'):
                            l[X][Y]='#'
    return 1
def find(a):
    global parent
    x=a[0]
    y=a[1]
    if(parent[i][j]==a):
        return a
    op=find(parent[i][j])
    parent[i][j]=op
    return op
def Union(a,b):
    global parent
    alpha=find(a)
    beta=find(b)
    if(alpha!=beta):
        parent[alpha[0]][alpha[1]]=[beta[0],beta[1]]
def isvalid(lofgood):
    for i in lofgood:
        if(find(i)!=find([n-1,m-1])):
            return 0
    return 1
t=int(input())
for you in range(t):
    l=input().split()
    n=int(l[0])
    m=int(l[1])
    l=[]
    for i in range(n):
        s=input()
        s=[k for k in s]
        l.append(s)
    if(modify(l)==0):
        print("No")
    else:
        lofgood=[]
        for i in range(n):
            for j in range(m):
                if(l[i][j]=='G'):
                    lofgood.append([i,j])
        parent=[[0 for i in range(m)]for i in range(n)]
        for i in range(n):
            for j in range(m):
                parent[i][j]=[i,j]
        for i in range(n):
            for j in range(m):
                dx=[-1,0,0,1]
                dy=[0,-1,1,0]
                for k in range(4):
                    for po in range(4):
                        X=i+dx[k]
                        Y=j+dy[po]
                        if(X<0 or X>=n):
                            continue
                        if(Y<0 or Y>=m):
                            continue
                        if(l[X][Y]=='#' or l[i][j]=='#'):
                            continue
                        Union([i,j],[X,Y])
        if(isvalid(lofgood)):
            print("Yes")
        else:
            print("No")