def find(ind1, ind2, tot, matrix, n, m):
    if(ind1 < 0 or ind1 >= n or ind2 < 0 or ind2 >= m):
        return
    if(matrix[ind1][ind2] == 'V'):
        return
    if(matrix[ind1][ind2] == '#' or matrix[ind1][ind2] == 'B'):
        return
    if(matrix[ind1][ind2] == 'G'):
        tot[0] += 1
    matrix[ind1][ind2] = 'V'
    find(ind1+1, ind2, tot, matrix, n, m)
    find(ind1-1, ind2, tot, matrix, n, m)
    find(ind1, ind2+1, tot, matrix, n, m)
    find(ind1, ind2-1, tot, matrix, n, m)

t = int(input())
for i in range(t):
    n, m = [int(x) for x in input().split()]
    matrix = []
    for i in range(n):
        matrix.append([x for x in input()])
    Goods = sum([matrix[i].count('G') for i in range(n)])
    if(Goods == 0):
        if(matrix[-1][-1] == 'B'):
            print('No')
        else:
            print('Yes')
        continue
    for i in range(n):
        for k in range(m):
            if(matrix[i][k] == 'B'):
                if(i > 0):
                    matrix[i-1][k] = '#'
                if(i < n-1):
                    matrix[i+1][k] = '#'
                if(k > 0):
                    matrix[i][k-1] = '#'
                if(k < m-1):
                    matrix[i][k+1] = '#'
    
    tot = [0]
    find(n-1, m-1, tot, matrix, n, m)
    #print(matrix)
    if(tot[0] == Goods):
        print('Yes')
    else:
        print('No')

    
