def f():
    return list(map(int,input().split()))
def sol():
    a,b=f()
    m=[]
    for _ in range(a):
        m.append(list(input()))
    g=0
    go=[[1,0],[0,1],[-1,0],[0,-1]]
    for i in range(a):
        for j in range(b):
            x=m[i][j]
            if x=='B':
                for p,q in go:
                    p+=i
                    q+=j
                    if 0<=p<a and 0<=q<b:
                        if m[p][q]=='G':
                            print('No')
                            return
                        if m[p][q]=='.':
                            m[p][q]='#'
            if x=='G':
                g+=1
    if g==0:
        print('Yes')
        return
    def dfs(p,q):
        nonlocal g
        stack=[[p,q]]
        while len(stack)!=0:
            p,q=stack.pop()
            if 0<=p<a and 0<=q<b:
                x=m[p][q]
                if x=='#':
                    continue
                if x=='G':
                    g-=1
                m[p][q]='#'
                for i,j in go:
                    stack.append((i+p,j+q))
    dfs(a-1,b-1)
    if g==0:
        print('Yes')
    else:
        print('No')
for _ in range(int(input())):
    sol()
    