import sys
input=sys.stdin.buffer.readline
inin=lambda typ=int: typ(input())
inar=lambda typ=int: [typ(x) for x in 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

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

Gloc=[]
Testcase=inin()
for _ in range(Testcase):
    Gloc=[]
    n,m=inar()
    maze=['' for i in range(n)]
    for i in range(n):
        maze[i]=list(inst())
    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:
        print('No')
    elif maze[n-1][m-1]=="#":
        if Gloc==[]:
            print('Yes')
        else:
            print('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:
            print('Yes')
        else:
            print('No')