num_cases = int(input())

for n in range(num_cases):
    input_list = [int(i) for i in input().split()]
    num_rows = input_list[0]
    num_cols = input_list[1]

    grid = []
    for i in range(num_rows):
        row = input()
        grid.append(list(row))

    possible = True
    goods = 0

    for i in range(num_rows):
        for j in range(num_cols):
            if grid[i][j] == "B":
                for k in [-1, 0, 1]:
                    for l in [-1, 0, 1]:
                        if abs(k + l) == 1:
                            if i + k < 0 or j + l < 0 or i + k >= num_rows or j + l >= num_cols:
                                continue
                            if grid[i + k][j + l] == "G":
                                possible = False
                            elif grid[i + k][j + l] != "B":
                                grid[i + k][j + l] = "#"
            elif grid[i][j] == "G":
                goods += 1

    visited = set()
    togo = [(num_rows - 1, num_cols - 1)]
    if possible and goods > 0:
        while togo:
            i, j = togo.pop()
            if grid[i][j] == "B":
                possible = False
                break
            elif grid[i][j] == "G":
                goods -= 1
            visited.add((i, j))
            for k in [-1, 0, 1]:
                for l in [-1, 0, 1]:
                    if abs(k + l) == 1:
                        if i + k < 0 or j + l < 0 or i + k >= num_rows or j + l >= num_cols:
                            continue
                        if grid[i + k][j + l] != "#" and (i + k, j + l) not in visited:
                            togo.append((i + k, j+ l))

    if goods == 0 and possible:
        print("Yes")
    else:
        print("No")

