import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nsmallest
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf
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(pow(10, 6))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = 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)]


def valid(a, b):
    return 0 <= a < n and 0 <= b < m


def bfs(a, b):
    q = deque()
    q.append((a, b))
    vis = [[False for i in range(m)] for j in range(n)]
    while q:
        t1, t2 = q.popleft()
        if (t1, t2) == (n-1, m-1):
            return True
        for k in range(4):
            a, b = t1+x[k], t2+y[k]
            if valid(a, b) and not vis[a][b] and mat[a][b] in ['B', 'G', '.']:
                vis[a][b] = True
                q.append((a, b))
                if (a, b) == (n-1, m-1):
                    return True
    return False


for _ in range(int(data())):
    n, m = sp()
    mat = []
    g = []
    for i in range(n):
        mat.append(list(data()))
        if 'G' in mat[i]:
            for j in range(m):
                if mat[i][j] == 'G':
                    g.append((i, j))
    x, y = [-1, 1, 0, 0], [0, 0, -1, 1]
    r = True
    for i in range(n):
        for j in range(m):
            if mat[i][j] == 'B':
                for k in range(4):
                    if valid(i+x[k], j+y[k]) and mat[i+x[k]][j+y[k]] == '.':
                        mat[i+x[k]][j+y[k]] = "#"
    for i in g:
        if not bfs(i[0], i[1]):
            r = False
            break
    out(("No", "Yes")[r])
