def set_norm(norm, n_i, n_j, n, m):
    if -1 < n_i < n and -1 < n_j < m:
        norm[n_i][n_j] = 1


def gettable(norm, i, j, used=None):
    if used is None:
        used = set()

    used.add((i, j))
    if i-1 >= 0 and norm[i-1][j] == 0:
        gettable(norm, i-1, j, used)
    if j-1 >= 0 and norm[i][j-1] == 0:
        gettable(norm, i, j-1, used)

    return used


def process():
    [n, m] = list(map(int, input().split(' ')))
    a = []

    for i in range(n):
        s = input().strip()
        a.append(s)

    norm = [[0 for j in range(m)] for i in range(n)]
    for i in range(n):
        for j in range(m):
            if a[i][j] == 'B':
                n_i, n_j = i, j
                set_norm(norm, n_i, n_j, n, m)
                n_i, n_j = i-1, j
                set_norm(norm, n_i, n_j, n, m)
                n_i, n_j = i+1, j
                set_norm(norm, n_i, n_j, n, m)
                n_i, n_j = i, j-1
                set_norm(norm, n_i, n_j, n, m)
                n_i, n_j = i, j+1
                set_norm(norm, n_i, n_j, n, m)

    goods = []
    for i in range(n):
        for j in range(m):
            if a[i][j] == 'G':
                goods.append((i, j))

    if len(goods) == 0 and a[i][j] == '.':
        print('Yes')
        return

    if norm[n-1][m-1] == 1:
        print('No')
    else:
        reachable = gettable(norm, n-1, m-1)
        for good in goods:
            if good not in reachable:
                print('No')
                break
        else:
            print('Yes')

t = int(input())

for _ in range(t):
    process()
