def grid_b(lab, n, m, pos_x, pos_y):
    result = 1
    lab[pos_x][pos_y] = '#'
    if pos_x > 0:
        if lab[pos_x - 1][pos_y] == 'G':
            result = 0
        elif lab[pos_x - 1][pos_y] != 'B':
            lab[pos_x - 1][pos_y] = '#'
    if pos_y > 0:
        if lab[pos_x][pos_y - 1] == 'G':
            result = 0
        elif lab[pos_x][pos_y - 1] != 'B':
            lab[pos_x][pos_y - 1] = '#'
    if pos_x < n - 1:
        if lab[pos_x + 1][pos_y] == 'G':
            result = 0
        elif lab[pos_x + 1][pos_y] != 'B':
            lab[pos_x + 1][pos_y] = '#'
    if pos_y < m - 1:
        if lab[pos_x][pos_y + 1] == 'G':
            result = 0
        elif lab[pos_x][pos_y + 1] != 'B':
            lab[pos_x][pos_y + 1] = '#'

    return result


def find_path(steps, lab, x, y, step):
    if lab[x][y] == '#':
        steps[x][y] = -1
    else:
        steps[x][y] = step
        step += 1
        if x > 0:
            if lab[x - 1][y] != '#' and steps[x - 1][y] == -1:
                find_path(steps, lab, x - 1, y, step)
        if x < n - 1:
            if lab[x + 1][y] != '#' and steps[x + 1][y] == -1:
                find_path(steps, lab, x + 1, y, step)

        if y > 0:
            if lab[x][y - 1] != '#' and steps[x][y - 1] == -1:
                find_path(steps, lab, x, y - 1, step)
        if y < m - 1:
            if lab[x][y + 1] != '#' and steps[x][y + 1] == -1:
                find_path(steps, lab, x, y + 1, step)


tests = int(input())
for i in range(tests):
    numbers = input().split(" ")
    n = int(numbers[0])
    m = int(numbers[1])

    lab = []
    for x in range(n):
        lab.append([])
        line = input()
        for y in range(m):
            lab[x].append(line[y])

    success = 1
    for x in range(n):
        for y in range(m):
            if lab[x][y] == 'B':
                success = grid_b(lab, n, m, x, y)
            if success == 0:
                break
        if success == 0:
            break

    if success == 0:
        print("No")
    else:
        steps = []
        for x in range(n):
            steps.append([])
            for y in range(m):
                steps[x].append(-1)

        find_path(steps, lab, n-1, m-1, 0)

        for x in range(n):
            for y in range(m):
                if lab[x][y] == 'G':
                    if steps[x][y] == -1:
                        success = 0
                if success == 0:
                    break
            if success == 0:
                break

        if success == 1:
            print("Yes")
        else:
            print("No")
