import collections
def f():
    n, m = [int(s) for s in input().split()]
    M = []
    for _ in range(n):
        M.append(list(input()))

    # showMatrix(M)

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

    def checkValid(i,j):
        if i < 0:
            return False
        if i >= n:
            return False
        if j < 0:
            return False
        if j>= n:
            return False
        return True

    def checkRound(i0,j0):
        for x, y in steps:
            i, j = i0+x, j0+y
            if checkValid(i,j):
                if M[i][j] == 'G':
                    return False
                if M[i][j] == '.':
                    M[i][j] = '#'
        return True

    def haveGood():
        for i in range(n):
            for j in range(m):
                if M[i][j] == 'G':
                    return True
        return False

    for i in range(n):
        for j in range(m):
            if M[i][j] == 'B':
                if not checkRound(i,j):
                    print('No')
                    return
    # showMatrix(M)
    if not haveGood():
        print('Yes')
        return

    if M[n-1][m-1] == '#':
        print('No')
        return

    q = collections.deque()
    q.append((n-1,m-1))
    while q:
        i0,j0 = q.popleft()
        for x,y in steps:
            i, j = i0+x, j0+y
            if checkValid(i,j):
                if M[i][j] == '.' or M[i][j] == 'G':
                    M[i][j] = ''
                    q.append((i,j))

    if haveGood():
        print('No')
        return
    print('Yes')




for t in range(int(input())):
    f()