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):
                    X=i+dx[k]
                    Y=j+dy[k]
                    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 BFS(x):
    global dist
    global visited
    if(l[x[0]][x[1]]=='#'):
        return
    visited[x[0]][x[1]]=1
    q=[x]
    dist[x[0]][x[1]]=0
    while(q!=[]):
        u=q[0]
        q.pop(0)
        dx=[-1,0,0,1]
        dy=[0,-1,1,0]
        for k in range(4):
            X=u[0]+dx[k]
            Y=u[1]+dy[k]
            if(X<0 or X>=n):
                continue
            if(Y<0 or Y>=m):
                continue
            if(visited[X][Y]!=1 and l[X][Y]!='#'):
                q.append([X,Y])
                visited[X][Y]=1
                dist[X][Y]=0
def isvalid(lofgood):
    for i in lofgood:
        if(dist[i[0]][i[1]]!=0):
            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])


        dist=[[-1 for i in range(m)]for j in range(n)]
        visited=[[0 for i in range(m)]for j in range(n)]
        BFS([n-1,m-1])
        if(isvalid(lofgood)):
            print("Yes")
        else:
            print("No")