import itertools
import copy
from queue import Queue

def satisfies(R, C, matrix):
    q = Queue()
    q.put( (R - 1, C - 1) )
    reached = set([])
    while not q.empty():
        r, c = q.get()
        if matrix[r][c] == '#':
            continue
        if matrix[r][c] == 'B':
            return False
        reached.add( (r, c) )
        for rn, cn in [(r-1, c), (r, c-1)]:
            if rn >= 0 and cn >= 0:
                q.put( (rn, cn) )
    for r in range(R):
        for c in range(C):
            if matrix[r][c] == 'G' and (r, c) not in reached:
                return False
    return True

def brute(R, C, matrix):
    possWalls = []
    for r in range(R):
        for c in range(C):
            if matrix[r][c] == '.':
                possWalls.append( (r, c) )
    for numWalls in range(len(possWalls) + 1):
        for walls in itertools.combinations(possWalls, numWalls):
            matrixCpy = copy.deepcopy(matrix)
            for rw, cw in walls:
                matrixCpy[rw][cw] = '#'
            if satisfies(R, C, matrixCpy):
                return 'Yes'
    return 'No'

def main():
    t = int(input())
    for _ in range(t):
        R, C = [int(x) for x in input().split()]
        matrix = []
        for _ in range(R):
            matrix.append([ch for ch in input()])
        # WARNING: CHANGE THIS!
        # print(matrix)
        result = brute(R, C, matrix)
        print(result)
main()