from collections import Counter
n = 100001


def mysieve(n):
    for i in xrange(2, n):
        if i * i <= n and not prime[i]:
            for j in xrange(i * i, n, i):
                prime[j] = 1


prime = [0] * n
prime[1] = 1
mysieve(n)
for i in xrange(input()):
    res = "YES"
    string = Counter(raw_input())
    if prime[len(string)] == 0:
        for val in string:
            
            if prime[string[val]]:
                res = "NO"
                break
    else:
        res = "NO"
    print res