import sys
from collections import deque as dq
input = sys.stdin.readline
def solve():
  H, W = map(int, input().split())
  a = [list(input())[: -1] for _ in range(H)]
  Q = dq([H * W - 1])
  d = [-1, 0, 1, 0]
  g = 0
  for y in range(H):
    for x in range(W):
      g |= a[y][x] == "G"
      if a[y][x] == "B":
        for k in range(4):
          u = y + d[k]
          v = x + d[-1 - k]
          if u in range(H) and (v in range(W)):
            if a[u][v] == "G":
              print("No")
              return
            if a[u][v] == ".": a[u][v] = "#"
  if g and (a[-1][-1] == "#"):
    print("No")
    return
  table = [0] * (H * W)
  while len(Q):
    p = Q.popleft()
    table[p] = 1
    y = p // W
    x = p % W
    for k in range(4):
      u = y + d[k]
      v = x + d[-1 - k]
      if u in range(H) and (v in range(W)):
        if table[u * W + v]: continue
        if a[u][v] == "#": continue
        table[u * W + v] = 1
        Q.append(u * W + v)
  for y in range(H):
    for x in range(W):
      if a[y][x] == "G":
        if table[y * W + x] == 0:
          print("No")
          return
  print("Yes")
  return
for _ in range(int(input())):
  solve()