import sys
input = sys.stdin.readline

t=int(input())
for tests in range(t):
    n,m=map(int,input().split())
    MAP=[list(input().strip()) for i in range(n)]

    for i in range(n):
        for j in range(m):
            if MAP[i][j]=="B":
                if 0<=i+1<n and 0<=j<m and MAP[i+1][j]==".":
                    MAP[i+1][j]="#"

                if 0<=i-1<n and 0<=j<m and MAP[i-1][j]==".":
                    MAP[i-1][j]="#"

                if 0<=i<n and 0<=j+1<m and MAP[i][j+1]==".":
                    MAP[i][j+1]="#"

                if 0<=i<n and 0<=j-1<m and MAP[i][j-1]==".":
                    MAP[i][j-1]="#"

    flag=1

    if MAP[n-1][m-1]=="#":
        Q=[]
    else:
        Q=[(n-1,m-1)]

    while Q and flag:
        x,y=Q.pop()

        for z,w in [(x+1,y),(x-1,y),(x,y+1),(x,y-1)]:
            if 0<=z<n and 0<=w<m:
                if MAP[z][w]=="B":
                    flag=0
                    break
                elif MAP[z][w]!="#":
                    MAP[z][w]="#"
                    Q.append((z,w))

    if flag==0:
        print("No")
        continue
    else:
        for i in range(n):
            for j in range(m):
                if MAP[i][j]=="G":
                    flag=0
                    break
            if flag==0:
                break

        if flag:
            print("Yes")
        else:
            print("No")
                
