t = int(input())

def nbs(sq, dims):
    (i,j) = sq
    (n, m) = dims
    res = []
    if i-1 >= 0:
        res.append((i-1, j))
    if j-1 >= 0:
        res.append((i, j-1))
    if i+1 <= n-1:
        res.append((i+1, j))
    if j+1 <= m-1:
        res.append((i, j+1))
    return res

def case():
    [n, m] = list(map(int, input().split()))
    maze = []
    Bs = []
    Gs = []
    for i in range(n):
        maze.append(list(input()))
        for j in range(m):
            sq = maze[i][j]
            if sq == "B":
                Bs.append((i,j))
            elif sq == "G":
                Gs.append((i,j))

    if len(Gs) == 0:
        return True

    for (i,j) in Bs:
        nbrs = nbs((i,j), (n,m))
        for nbr in nbrs:
            inb, jnb = nbr[0], nbr[1]
            if maze[inb][jnb] == "G" or (inb, jnb) == (n-1,m-1):
                return False
            elif maze[inb][jnb] != "B":
                maze[inb][jnb] = "#"

    cc = [(n-1,m-1)]
    wave = [(n-1,m-1)]
    Gs_in_cc = 0
    while len(wave) > 0:
        # print(cc, wave)
        new_wave = []
        for sq in wave:
            for (i,j) in nbs(sq, (n,m)):
                if (i, j) not in cc:
                    cand = maze[i][j]
                    if cand == ".":
                        new_wave.append((i,j))
                    elif cand == "G":
                        new_wave.append((i,j))
                        Gs_in_cc += 1
        wave = new_wave
        # print(cc, wave)
        cc += wave

    if Gs_in_cc == len(Gs):
        return True
    else:
        return False


for test_case in range(t):
    poss = case()
    if poss:
        print("Yes")
    else:
        print("No")
