def readintlst():
    return list(map(int, input().split(' ')))


def readcharlst():
    return list(input().split(' '))


def readn():
    return int(input())


directions = [(1, 0), (-1, 0), (0, 1), (0, -1)]


def main(n, m, mat):
    # print(mat)
    gg = set()
    for i in range(n):
        for j in range(m):
            if mat[i][j] == 'B':
                for di, dj in directions:
                    ii, jj = i + di, j + dj
                    if 0 <= ii < n and 0 <= jj < m:
                        if mat[ii][jj] == 'G':
                            return False
                        elif mat[ii][jj] == '.':
                            mat[ii][jj] = '#'
            if mat[i][j] == 'G':
                gg.add((i, j))

    q = [(n - 1, m - 1)]
    visited = set((n - 1, m - 1))
    if mat[n - 1][m - 1] == '#':
        if gg:
            return False
        else:
            return True

    # [print(r) for r in mat]
    # print('--' * 15)
    while q:
        nq = []
        # print(q)
        for i, j in q:
            for di, dj in directions:
                ii, jj = i + di, j + dj
                if 0 <= ii < n and 0 <= jj < m \
                and (ii, jj) not in visited and mat[ii][jj] != '#':
                    visited.add((ii, jj))
                    nq.append((ii, jj))
                    if (ii, jj) in gg:
                        gg.remove((ii, jj))

        q = nq
    # print(gg)
    if gg:
        return False
    else:
        return True


for _ in range(readn()):
    n, m = readintlst()
    mat = []
    for _ in range(n):
        mat.append(list(input()))
    if main(n, m, mat):
        print('yes')
    else:
        print('no')