#BECAUSE ONE TRUTH PREVAILS
import sys
def dfs(i,j,vis,L,N,M):
    if L[i][j]!='#' and L[i][j]!='B' and vis[i][j]==0:
        vis[i][j]=1
        if i+1<N:
            dfs(i+1,j,vis,L,N,M)
        if i-1>=0:
            dfs(i-1,j,vis,L,N,M)
        if j-1>=0:
            dfs(i,j-1,vis,L,N,M)
        if j+1<M:
            dfs(i,j+1,vis,L,N,M)
def arr():
    return list(map(int,input().split()))
input=sys.stdin.readline
from collections import defaultdict
for _ in range(int(input())):
    N,M=map(int,input().split())
    L=[]
    for i in range(N):
        L.append(list(input()))
        L[i].pop()
    flag=True
    for i in range(N):
        for j in range(M):
            if L[i][j]=='B':
                if i+1<N:
                    if L[i+1][j]=='G':
                        flag=False
                        break
                if i-1>=0:
                    if L[i-1][j]=='G':
                        flag=False
                        break
                if j-1>=0:
                    if L[i][j-1]=='G':
                        flag=False
                        break
                if j+1<M:
                    if L[i][j+1]=='G':
                        flag=False
                        break
    if L[N-1][M-1]=='#' or L[N-1][M-1]=='B':
        flag=False
    if flag==False:
        print("No")
    else:
        for i in range(N):
            for j in range(M):
                if L[i][j]=='B':
                    if i+1<N:
                        if L[i+1][j]=='.':
                            L[i+1][j]='#'
                    if i-1>=0:
                        if L[i-1][j]=='.':
                            L[i-1][j]='#'
                    if j-1>=0:
                        if L[i][j-1]=='.':
                            L[i][j-1]='#'
                    if j+1<M:
                        if L[i][j+1]=='.':
                            L[i][j+1]='#'
        for i in range(N):
            vis=[]
            for k in range(N):
                vis.append([0]*M)
            for j in range(M):
                if L[i][j]=='G':
                    dfs(i,j,vis,L,N,M)
                    if vis[N-1][M-1]==0:
                        flag=False
                        break
        if flag:
            print("Yes")
        else:
            print("No")