import math
from collections import defaultdict
def r():
    return int(input())
def rm():
    return map(int,input().split())
def rl():
    return list(map(int,input().split()))

dir = [[0,1],[0,-1],[1,0],[-1,0]]
def valid(i,j,n,m):
    return i>=0 and i<n and j>=0 and j<m
for _ in range(r()):
    n,m=rm()
    li=[]
    for i in range(n):
        li.append(list(input()))

    for i in range(n):
        for j in range(m):
            if li[i][j]=='B':
                for k in dir:
                    ki=i+k[0]
                    kj=j+k[1]
                    if valid(ki,kj,n,m):
                        if li[ki][kj]=='.':
                            li[ki][kj]='#'

    queue=[]
    visited=defaultdict(bool)
    if li[n-1][m-1]=='.':
        queue.append((n-1,m-1))
        visited[(n-1,m-1)]=True
    while queue:
        i,j=queue.pop(0)
        visited[(i,j)]=True
        for k in dir:
            ni,nj=i+k[0],j+k[1]
            if valid(ni,nj,n,m):
                if (not visited[(ni,nj)]) and li[ni][nj]!='#':
                    queue.append((ni,nj))
                visited[(ni,nj)]=True

    good=True
    for i in range(n):
        for j in range(m):
            if (li[i][j]=='G' and not visited[(i,j)]) or (li[i][j]=='B' and visited[(i,j)]):
                good=False
                break

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