def eratosthenes2(n):
    multiples = set()
    primes = []
    for i in range(2, n+1):
        if i not in multiples:
            primes.append(i)
            multiples.update(range(i*i, n+1, i))
    return primes


def is_prime_string(string):
    primes = []
    chars = set(string)
    primes.append(len(chars))

    for char in chars:
        primes.append(string.count(char))

    all_primes = eratosthenes2(max(primes) + 1)

    flag = -1
    for number in primes:
        if(number in all_primes):
            continue
        else:
            flag = -2
            break
    else:
        return 'YES'

    if(flag == -2):
        return 'NO'

T = int(raw_input())
for t in range(T):
    print is_prime_string(raw_input())