import sys
input = sys.stdin.readline
def solve():
  N, M = map(int, input().split())
  a = [list(input())[: -1] for _ in range(N)]
  d = [-1, 0, 1, 0]
  for i in range(N):
    for j in range(M):
      if a[i][j] == "B":
        for k in range(4):
          y = i + d[k]
          x = j + d[-1 - k]
          if y in range(N) and (x in range(M)):
            if a[y][x] == "G": return False
            if a[y][x] == ".": a[y][x] = "#"
  vis = [0] * (N * M)
  s = [N * M - 1]
  if a[-1][-1] == ".":
    vis[-1] = 1
    while len(s):
      p = s.pop()
      i = p // M
      j = p % M
      for k in range(4):
        y = i + d[k]
        x = j + d[-1 - k]
        q = y * M + x
        if y in range(N) and (x in range(M)):
          if a[y][x] == "#": continue
          if vis[q]: continue
          vis[q] = 1
          s.append(q)
  for i in range(N):
    for j in range(M):
      if a[i][j] == "G" and (vis[i * M + j] == 0): return False
  return True
for _ in range(int(input())):
  if solve(): print("Yes")
  else: print("No")