def isPoss(i, j, mat, poss, n, m):
    if mat[i][j] == 'B' or mat[i][j] == '#':
        poss[i][j] = 0
    if poss[i][j] == -1:
        poss[i][j] = 0
        if i - 1 >= 0:
            poss[i][j] = poss[i][j] | isPoss(i - 1, j, mat, poss, n, m)
        if i + 1 < n:
            poss[i][j] = poss[i][j] | isPoss(i + 1, j, mat, poss, n, m)
        if j - 1 >= 0:
            poss[i][j] = poss[i][j] | isPoss(i, j - 1, mat, poss, n, m)
        if j + 1 < m:
            poss[i][j] = poss[i][j] | isPoss(i, j + 1, mat, poss, n, m)
    return poss[i][j]

for _ in range(int(input())):
    n, m = map(int, input().split())
    mat = []
    poss = [[-1 for i in range(m)]for i in range(n)]
    poss[n - 1][m - 1] = 1
    bad = []
    good = []
    for i in range(n):
        mat.append(list(input()))
        for j in range(m):
            if mat[i][j] == 'B':
                bad.append([i, j])
            elif mat[i][j] == 'G':
                good.append([i, j])

    for i in range(n):
        for j in range(m):
            if poss[i][j] == -1:
                isPoss(i, j, mat, poss, n, m)

    flag = 1
    for t in bad:
        i = t[0]
        j = t[1]
        if i - 1 >= 0 and poss[i - 1][j] == 1:
            if mat[i - 1][j] == 'G':
                flag = 0
                break
            mat[i - 1][j] = '#'

        if i + 1 < n and poss[i + 1][j] == 1:
            if mat[i + 1][j] == 'G':
                flag = 0
                break
            mat[i + 1][j] = '#'

        if j - 1 >= 0 and poss[i][j - 1] == 1:
            if mat[i][j - 1] == 'G':
                flag = 0
                break
            mat[i][j - 1] = '#'

        if j + 1 < m and poss[i][j + 1] == 1:
            if mat[i][j + 1] == 'G':
                flag = 0
                break
            mat[i][j + 1] = '#'

    if flag != 0:
        poss1 = [[-1 for i in range(m)]for i in range(n)]
        poss1[n - 1][m - 1] = 1
        for i in range(n):
            for j in range(m):
                if poss1[i][j] == -1:
                    isPoss(i, j, mat, poss1, n, m)
        for t in good:
            if poss1[t[0]][t[1]] == 0:
                flag = 0
                break
    # print(poss1)
    print('No' if flag == 0 else 'Yes')

