import sys

t = int(input())
for _t in range(t):
    n, m = map(int, sys.stdin.readline().split())
    L = []
    goods = []
    bads = []
    for i in range(n):
        row = list(input())
        for j, cell in enumerate(row):
            if cell == 'B':
                bads.append((i, j))
            elif cell == 'G':
                goods.append((i, j))

        L.append(row)

    go_next = False

    for i, j in bads:
        for di, dj in ((1, 0), (-1, 0), (0, -1), (0, 1)):
            if n > i + di > -1 and m > j + dj > -1:
                if L[i + di][j + dj] == 'G':
                    print('No')
                    go_next = True
                    break

                elif L[i + di][j + dj] != 'B':
                    L[i + di][j + dj] = '#'

        if go_next:
            break

    if go_next:
        continue

    if L[n - 1][m - 1] == '#':
        if goods:
            print('No')
        else:
            print('Yes')
        continue

    # проверка пути для всех хороших
    for i, j in goods:
        L[i][j] = '.'

    for person_id, good_person in enumerate(goods, 1):
        gi, gj = good_person
        check = [(gi, gj)]
        L[gi][gj] = person_id
        next_person = False
        while check:
            new_check = []
            for i, j in check:
                for di, dj in ((1, 0), (-1, 0), (0, -1), (0, 1)):
                    if n > i + di > -1 and m > j + dj > -1:
                        cell = L[i + di][j + dj]
                        # print('*', cell, type(cell), cell is 'int')
                        if type(cell) is int:
                            if cell < person_id:
                                next_person = True
                                break
                            continue

                        if cell == '#':
                            continue

                        L[i + di][j + dj] = person_id
                        new_check.append((i + di, j + dj))

            check = new_check

        if next_person:
            continue

        if L[n - 1][m - 1] != person_id:
            print('No')
            go_next = True
            break

    if go_next:
        continue

    print('Yes')
