from sys import *
t = int(input())
idir = [1, 0, -1, 0]
jdir = [0, 1, 0, -1]

def solve():
  h, w = map(int, input().split())
  mat = [input() for _ in range(h)]
  hasg = 0
  for r in mat:
    for ch in r:
      if ch == 'G':
        hasg = 1
        break
    if hasg: break
  if hasg == 0:
    print('Yes')
    return
  fail = 0

  blocked = set()

  for i in range(h):
    for j in range(w):
      if mat[i][j] == 'B':
        for k in range(4):
          ni = i + idir[k]
          nj = j + jdir[k]
          if ni < 0 or ni >= h or nj < 0 or nj >= w or mat[ni][nj] == 'B': continue
          if mat[ni][nj] == 'G':
            fail = 1
            break
          blocked.add((ni, nj))
      if fail: break
    if fail: break

  reach = [[0 for _ in range(w)] for _ in range(h)]
  q = []
  if not (h-1, w-1) in blocked:
    q.append((h - 1, w - 1))
    reach[h-1][w-1] = 1
  front = 0
  while front < len(q):
    i, j = q[front]
    front += 1
    for k in range(4):
      ni = i + idir[k]
      nj = j + jdir[k]
      if ni < 0 or ni >= h or nj < 0 or nj >= w or mat[ni][nj] == '#' or reach[ni][nj] or (ni, nj) in blocked: continue
      q.append((ni, nj))
      reach[ni][nj] = 1
  for i in range(h):
    for j in range(w):
      if mat[i][j] == 'G' and reach[i][j] == 0:
        fail = 1
        break
    if fail: break
  if fail: print('No')
  else: print('Yes')

for _ in range(t):
  solve()
