from collections import Counter

def primecheck(n):
    return all(n % i for i in xrange(2, n))

def check(string):
    counter = Counter(string)
    
    if primecheck(len(set(string))) == 1 and len(set(string)) != 1:
        for i in set(string):
            if primecheck(counter[i]) == 0 or counter[i] == 1:
                return "NO"
        return "YES"
    return "NO"

n = input("")
for i in range(n):
    string = raw_input("")
    print check(string)