t=int(input())

ans=['Yes']*t

import copy

for times in range(t):
  Y,X=map(int,input().split())
  
  raw=["#"]+["."]*(601)+["#"]
  lastraw=["#"]*(X+2)
  field=[["#"]*(X+2)]
  for i in range(Y):
    s=list(input())
    s.insert(0,"#")
    s.append("#")
    #print(s)
    field.append(s)
  field.append(lastraw)
  #print(field)

  startqueue=[]
  moves=0
  tests = ((0, 1),(1, 0),(-1, 0),(0, -1))

  if field[Y][X]=='B':
    moves=-1
  
  for i in range(1,Y+1):
    for j in range(1,X+1):
      if field[i][j]=='G':
        startqueue.append([i,j])
        #field[i][j]="."
      elif field[i][j]=='B':
        for ny, nx in tests:
          ty, tx = i + ny, j + nx
          if field[ty][tx] == 'G':
            moves=-1
          elif field[ty][tx] == '.':
            field[ty][tx]="#"
        field[i][j]="#"
  goal_point=(Y+1,X+1)

  savedfield=copy.deepcopy(field)

  while True:
    #print(moves)
    if field[Y][X]=='#' and len(startqueue)!=0:
    	moves=-1
    if moves==-1:
      ans[times]='No'
      break
    if len(startqueue)==0:
      break
    #field=copy.deepcopy(savedfield)
    [sy,sx]=[Y,X]
    [gy,gx]=[0,0]

    field[sy][sx]=0
    queue=[[sy,sx]] 
    moves=0

    while True:
      #print(len(queue))
      if len(queue)==0:
        moves=-2
        break
      #print(field)
      queue_next = []
      moves += 1
      for y, x in queue:
        for ny, nx in tests:
          ty, tx = y + ny, x + nx
          #print(ty,tx)
          if field[ty][tx] == '.' or field[ty][tx] == 'G':
            field[ty][tx] = moves
            queue_next.append((ty, tx))
      queue = queue_next
      if goal_point in queue:
        break
    for i in range(len(startqueue)):
      [a,b]=startqueue[i]
      #print(len(startqueue)-1,i)
      if field[a][b]=='G':
        ans[times]='No'
        break
      elif len(startqueue)-1==i:
        break
    else: 
      continue
    break
 
    #print(moves)


for i in range(t):
  print(ans[i])