directions = [(0, 1), (1, 0), (-1, 0), (0, -1)]
def solve(matrix,  n,m):
    for i in range(n):
        for j in range(m):
            if matrix[i][j] == 'B':
                for di, dj in directions:
                    ni = i + di
                    nj = j + dj
                    if 0<=ni<n and 0<=nj<m:
                        if matrix[ni][nj] == 'G':
                            return False
                        if matrix[ni][nj] != 'B':
                            matrix[ni][nj] = '#'


    q = []
    visited = set()
    if matrix[-1][-1] != '#':
        q.append((n-1, m-1))
        visited.add((n-1, m-1))
    while q:
        i, j = q.pop()
        for di, dj in directions:
            ni = i + di
            nj = j + dj
            if (ni, nj) not in visited and 0<=ni<n and 0<=nj<m and matrix[ni][nj] != '#':
                q.append((ni, nj))
                visited.add((ni, nj))

    for i in range(n):
        for j in range(m):
            if matrix[i][j] == 'G' and (i, j) not in visited:
                return False
    return True

t = int(input())
for _ in range(t):
    n, m = list(map(int, input().split()))
    matrix = []
    for i in range(n):
        matrix.append([x for x in input()])
    if solve(matrix, n, m):
        print('Yes')
    else:
        print('No')