from collections import deque


def solve():
    n, m = map(int, input().split(" "))
    matrix = []
    for _ in range(n):
        matrix.append(list(input()))

    n_good = 0
    directions = [(0, 1), (0, -1), (1, 0), (-1, 0)]
    for i in range(n):
        for j in range(m):
            if matrix[i][j] == 'G':
                n_good += 1
            elif matrix[i][j] == 'B':
                for di, dj in directions:
                    if di + i < 0 or di + i >= n or dj + j < 0 or dj + j >= m or matrix[di + i][dj + j] == 'B':
                        continue
                    elif matrix[di + i][dj + j] == 'G':
                        return "No"
                    matrix[di + i][dj + j] = '#'

    if n_good == 0:
        return "Yes"
    if n_good != 0 and  matrix[n - 1][m - 1] == '#':
        return "No"

    q = deque()
    q.append((n - 1, m - 1))
    matrix[n - 1][m - 1] = '#'

    while q:
        i, j = q.popleft()
        for di, dj in directions:
            if di + i < 0 or di + i >= n or dj + j < 0 or dj + j >= m or matrix[di + i][dj + j] == '#':
                continue
            if matrix[di + i][dj + j] == 'G':
                n_good -= 1

            matrix[di + i][dj + j] = '#'
            q.append((di + i, dj + j))

    return "Yes" if n_good == 0 else "No"


T = int(input())
for _ in range(T):
    print(solve())