from collections import deque
test = int(input())
for _ in range(test):
    n, m = map(int, input().split())
    mat = []
    good = 0
    gg = []
    bd = []
    bad = 0
    for i in range(n):
        col = list(input())
        for j in range(m):
            if col[j]=='G':
                good+=1
                gg.append((i,j))
            elif col[j]=='B':
                bad+=1
                bd.append((i,j))
        mat.append(col)

    dircn = [-1,0,1,0,-1]
    flag = True
    if bad:
        for b in range(bad):
            i,j = bd[b]
            for k in range(4):
                x = i+dircn[k]
                y = j+dircn[k+1]

                if n>x>=0 and m>y>=0:
                    if mat[x][y]=='G' or (x==n-1 and y==m-1 and good>0):
                        print('No')
                        flag = False
                        break
                    elif mat[x][y]=='.':
                        mat[x][y]=='#'
            
            if flag==False:
                break

    if flag:
        if good==0:
            print('Yes')
        else:
            q = deque([(n-1,m-1)])
            vis = set()
            res= False
            while len(q) and good:
                r,c = q.pop()
                vis.add((r,c))
                for k in range(4):
                    x = r + dircn[k]
                    y = c + dircn[k+1]
            
                    if n>x>=0 and m>y>=0:
                        if mat[x][y]=='G' and (x,y) not in vis:
                            good-=1
                            q.append((x,y))
                        elif mat[x][y]=='.' and (x,y) not in vis:
                            q.append((x,y))
            
            if good:
                print('No')
            else:
                print('Yes')