# Code Forces 648: D: Solve The Maze.
# Sun. Jun. 7, 2020, By: arccosh.

from collections import Counter

dirs = zip((1, 0, -1, 0), (0, 1, 0, -1))

def reach(h, w, maze):
  ret = [[0] * w for _ in xrange(h)]
  q = []
  def try_add(r, c):
    if 0 <= r < h and 0 <= c < w:
      if ret[r][c] == 0 and maze[r][c] != '#':
        ret[r][c] = 1
        q.append((r, c))
  try_add(h - 1, w - 1)
  head = 0
  while head < len(q):
    r0, c0 = q[head]
    head += 1
    for dr, dc in dirs:
      try_add(r0 + dr, c0 + dc)
  return ret

def solve(h, w, maze):
  gpos = []
  bpos = []
  for i in xrange(h):
    for j, ch in enumerate(maze[i]):
      if ch == 'G':
        gpos.append((i, j))
      elif ch == 'B':
        bpos.append((i, j))
  for br, bc in bpos:
    for dr, dc in dirs:
      r, c = br + dr, bc + dc
      if not(0 <= r < h and 0 <= c < w):
        continue
      if maze[r][c] == 'G':
        return 0
      if maze[r][c] == '.':
        maze[r][c] = '#'
  xp = reach(h, w, maze)
  if any(xp[r][c] == 0 for r, c in gpos) or any(xp[r][c] == 1 for r, c in bpos):
    return 0
  return 1

for ca in xrange(int(raw_input())):
  h, w = (int(t) for t in raw_input().split())
  maze = [list(raw_input().strip()) for _ in xrange(h)]
  print(['No', 'Yes'][solve(h, w, maze)])
