import bisect
import sys
import math
input = sys.stdin.readline

from collections import defaultdict

############ ---- Input Functions ---- ############

def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))

############ ---- Solution ---- ############

def dfs(b, i, j, visited):
    stack = [(i, j)]

    while len(stack) > 0:
        i, j = stack.pop()
        visited[i][j] = True
        for di, dj in [(i-1, j), (i, j-1), (i, j+1), (i+1, j)]:
            if di < 0 or di >= len(b) or dj < 0 or dj >= len(b[di]):
                continue
            if b[di][dj] == "#":
                continue
            if visited[di][dj]:
                continue
            stack.append((di, dj))

def solve2(case):
    [n, m] = inlt()
    b = [list(input().strip()) for i in range(n)]

    gcount = sum(sum(1 if c == "G" else 0 for c in row) for row in b)
    bcount = sum(sum(1 if c == "B" else 0 for c in row) for row in b)

    if b[-1][-1] == "B":
        return False

    if gcount == 0:
        return True

    for i in range(n):
        for j in range(m):
            if b[i][j] == "B":
                for di, dj in [(i-1, j), (i, j-1), (i, j+1), (i+1, j)]:
                    if di < 0 or di >= n or dj < 0 or dj >= m:
                        continue
                    if b[di][dj] == ".":
                        b[di][dj] = "#"
    
    visited = [[False for _ in range(m)] for _ in range(n)]

    dfs(b, n-1, m-1, visited)

    gvis = sum(sum(1 if b[i][j] == "G" and visited[i][j] else 0 for j in range(m)) for i in range(n))
    bvis = sum(sum(1 if b[i][j] == "B" and visited[i][j] else 0 for j in range(m)) for i in range(n))

    return gvis == gcount and bvis == 0
    
def solve(case):
    return "Yes" if solve2(case) else "No"


if len(sys.argv) > 1 and sys.argv[1].startswith("input"):
    f = open("./" + sys.argv[1], 'r')
    input = f.readline

T = inp()
for i in range(T):
    res = solve(i+1)
    print(str(res))
