import sys
input=sys.stdin.buffer.readline
inin=lambda: int(input())
inar=lambda: list(map(int,input().split()))
inst=lambda: input().decode().rstrip('\n\r')
INF=float('inf')
#from collections import deque as que, defaultdict as vector, Counter
#from bisect import bisect
#from heapq import heapify, heappush as hpush, heappop as hpop
from types import GeneratorType
def recursive(f, stack=[]):
    def wrappedfunc(*args, **kwargs):
        if stack:
            return f(*args, **kwargs)
        else:
            to = f(*args, **kwargs)
            while True:
                if type(to) is GeneratorType:
                    stack.append(to)
                    to = next(to)
                else:
                    stack.pop()
                    if not stack:
                        break
                    to = stack[-1].send(to)
            return to
    return wrappedfunc

def yes():
    print('Yes')
def no():
    print('No')
n,m=0,0
maze=[]
dx=[-1,1,0,0]
dy=[0,0,-1,1]
@recursive
def dfs(i,j,visited):
    visited[i][j]=True
    for delta in range(4):
        x=j+dx[delta]
        y=i+dy[delta]
        if x>=0 and y>=0 and x<m and y<n and visited[y][x]==False:
            #print(x,y)
            if maze[y][x]=='.' or maze[y][x]=='G':
                yield dfs(y,x,visited)
    yield
def main():
    Gloc=[]
    Testcase=inin()
    for _ in range(Testcase):
        Gloc=[]
        global n
        global m
        global maze
        n,m=inar()
        maze=['' for i in range(n)]
        for i in range(n):
            maze[i]=list(input().decode())
        pasapasi=False
        for i in range(n):
            for j in range(m):
                if maze[i][j]=='G':
                    Gloc.append((i,j))
                if maze[i][j]=='B':
                    for delta in range(4):
                        x=j+dx[delta]
                        y=i+dy[delta]
                        if x>=0 and y>=0 and x<m and y<n:
                            if maze[y][x]=='G':
                                pasapasi=True 
                                break 
                            if maze[y][x]=='.':
                                maze[y][x]='#'
     
        if pasapasi:
            no()
        elif maze[n-1][m-1]=="#":
            if Gloc==[]:
                yes()
            else:
                no()
        else:
     
            visited=[[False for j in range(m)] for i in range(n)]
            dfs(n-1,m-1,visited)
            cond=True
            for i,j in Gloc:
                cond = cond and visited[i][j]
            if cond:
                yes()
            else:
                no()

main()