def getAdj(x, y, N, M) :
  moves = [(-1, 0), (1, 0), (0, -1), (0, 1)]
  adj = []
  for dx, dy in moves :
    if x+dx < 0 or x+dx >= M : continue
    if y+dy < 0 or y+dy >= N : continue
    adj.append((x+dx,y+dy))
  return adj

T = input()
for t in range(T) :
  N, M = map(int,raw_input().split())

  good, bad = set(), []
  grid = []
  for n in range(N) :
    row = list(raw_input())
    grid.append(row)
    for m in range(M) :
      if row[m] == 'G' : good.add((n,m))
      if row[m] == 'B' : bad.append((n,m))
  
  valid = True
  for n, m in bad :
    if N-n + M-m <= 3 : valid = False
    adj = getAdj(m,n,N,M)

    for x, y in adj :
      if grid[y][x] == '#' : continue
      elif grid[y][x] == '.' : grid[y][x] = '#'
      else : 
        valid = False
        break

    if not valid : break
  
  if not valid and len(good) == 0 : print "Yes"
  elif not valid and len(good) > 0 : print "No"
  else :

    marked = [[False]*M for n in range(N)]
    q = [(N-1,M-1)]
    marked[N-1][M-1] = True

    while q :
      curY, curX = q.pop()
      if len(good) == 0 : break

      for x, y in getAdj(curX, curY, N, M) :
        if grid[y][x] == '#' : continue
        if marked[y][x] : continue
        marked[y][x] = True
        good.discard((y,x))
        q.append((y,x))

    print "Yes" if len(good) == 0 else "No"