def foo(string):
    freq = {}

    for char in string:
        freq.setdefault(char, 0)
        freq[char] += 1

    AllPrime = True

    if isPrime(len(freq)):
        for i in freq.values():
            if isPrime(i):
                continue
            else:
                AllPrime = False
                break
        if AllPrime:
            return 'YES'
        else:
            return 'NO'
    else:
        return 'NO'

def isPrime(n):
    if n == 2:
        return True
    elif 2 ** (n-1) % n == 1:
        return True
    else:
        return False

T = int(raw_input())
for tc in range(T):
    string = raw_input().strip()
    print foo(string)