def isNumPrime(num):
    if num > 1:
        for i in range(2, num):
            if (num % i) == 0:
                return False
        else:
            return True
    else:
        return False
       


def isStringPrime(string):
    dict = {}
    for c in string:
        if dict.has_key(c):
            dict[c] += 1
        else:
            dict[c] = 1
    
    if isNumPrime(len(dict)) is False:
        return False
    
    for value in dict.values():
        if isNumPrime(value) is False:
            return False
    
    return True


if __name__ == '__main__':

    t = int(raw_input())
    for i in xrange(t):
        string = raw_input()
        if isStringPrime(string):
            print 'YES'
        else:
            print 'NO'