import math
def primeSieve(no):
    sieveSize=no+1
    sieve = [True] * sieveSize
    sieve[0] = False
    sieve[1] = False
    for i in xrange(2, int(math.sqrt(sieveSize)) + 1):
        pointer = i * 2
        while pointer < sieveSize:
            sieve[pointer] = False
            pointer += i
    primes = []
    for i in xrange(sieveSize):
        if sieve[i] == True:
            primes.append(i)
    if no in primes:
        return True
    else:
        return False
# print len(primeSieve(int(raw_input())))


for x in xrange(int(raw_input())):
    string=raw_input()
    d=dict()
    for c in string:
        if c not in d:
            d[c]=1
        else:
            d[c]+=1
    key_len=len(d.keys())
    distinct_check=primeSieve(key_len)
    # print distinct_check
    no_check=False
    for s in d.values():
        if primeSieve(s) is False:
            no_check=False
            break
        else:
            no_check=True
    if distinct_check and no_check:
        print 'YES'
    else:
        print 'NO'