def checker(labr, n, m):
    taken = set()
    to_take = set()
    to_take.add(tuple([n - 1, m - 1]))
    amm = 0
    while len(to_take) > 0:
        i = to_take.pop()
        if i[0] - 1 >= 0 and labr[i[0] - 1][i[1]] != '#' and not (i[0] - 1, i[1]) in taken:
            if labr[i[0] - 1][i[1]] == 'G':
                amm += 1
            if not tuple([i[0] - 1, i[1]]) in taken:
                to_take.add(tuple([i[0] - 1, i[1]]))
        if i[1] - 1 >= 0 and labr[i[0]][i[1] - 1] != '#' and not (i[0], i[1] - 1) in taken:
            if labr[i[0]][i[1] - 1] == 'G':
                amm += 1
            if not tuple([i[0], i[1] - 1]) in taken:
                to_take.add(tuple([i[0], i[1] - 1]))
        if i[0] + 1 < n and labr[i[0] + 1][i[1]] != '#' and not (i[0] + 1, i[1]) in taken:
            if labr[i[0] + 1][i[1]] == 'G':
                amm += 1
            if not tuple([i[0], i[1] - 1]) in taken:
                to_take.add(tuple([i[0] + 1, i[1]]))
        if i[1] + 1 < m and labr[i[0]][i[1] + 1] != '#' and not (i[0], i[1] + 1) in taken:
            if labr[i[0]][i[1] + 1] == 'G':
                amm += 1
            if not tuple([i[0], i[1] + 1]) in taken:
                to_take.add(tuple([i[0], i[1] + 1]))
        taken.add(i)
    return amm


def main():
    n, m = map(int, input().split())
    labr = []
    for i in range(n):
        line = list(input())
        labr.append(line)
    good = 0
    for i in range(n):
        for k in range(m):
            if labr[i][k] == 'G':
                good += 1
            if labr[i][k] == 'B':

                if i - 1 >= 0:
                    if labr[i - 1][k] == 'G':
                        print('No')
                        return
                    elif labr[i - 1][k] == 'B':
                        pass
                    else:
                        labr[i - 1][k] = '#'
                if i + 1 < n:
                    if labr[i + 1][k] == 'G':
                        print('No')
                        return
                    elif labr[i + 1][k] == 'B':
                        pass
                    else:
                        labr[i + 1][k] = '#'
                if k - 1 >= 0:
                    if labr[i][k - 1] == 'G':
                        print('No')
                        return
                    elif labr[i][k - 1] == 'B':
                        pass
                    else:
                        labr[i][k - 1] = '#'
                if k + 1 < m:
                    if labr[i][k + 1] == 'G':
                        print('No')
                        return
                    elif labr[i][k + 1] == 'B':
                        pass
                    else:
                        labr[i][k + 1] = '#'
    if labr[n - 1][m - 1] == '#':
        if good > 0:
            print("No")
            return
        else:
            print('Yes')
            return
    amm = checker(labr, n, m)
    if amm == good:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    t = int(input())
    for i in range(t):
        main()
