import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
sys.setrecursionlimit(int(pow(10,6)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]
# @lru_cache(None)

DIR = [(-1, 0), (1, 0), (0, -1), (0, 1)]
 
def dfs(i, j):
    if i > n or i == 0 or j > m or j == 0:
        return
    used[i][j] = 1
    for di, dj in DIR:
        if not used[i + di][j + dj] and a[i + di][j + dj] != "#":
            dfs(i + di, j + dj)
            
 
for t in range(int(input())):
    n, m = list(map(int, input().split()))
    a = [["#"] * (m + 2)] + [list("#" + input() + "#") for i in range(n)] + [["#"] * (m + 2)]
    used = [[0] * (m + 2) for i in range(n + 2)]
    ok = True
    for i in range(1, n + 1):
        for j in range(1, m + 1):
            if a[i][j] == "B":
                for di, dj in DIR:
                    if a[i + di][j + dj] == "G":
                        ok = False
                    elif a[i + di][j + dj] != "B":
                        a[i + di][j + dj] = "#"
    if a[n][m] != "#":
        dfs(n, m)
    for i in range(1, n + 1):
        for j in range(1, m + 1):
            if a[i][j] == "G" and not used[i][j]:
                ok = False
    print("Yes" if ok else "No")