'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
#print 'Hello World!'
from collections import Counter

number  = int (raw_input())


def isprime(n):
    '''check if integer n is a prime'''
    # make sure n is a positive integer
    n = abs(int(n))
    # 0 and 1 are not primes
    if n < 2:
        return False
    # 2 is the only even prime number
    if n == 2: 
        return True    
    # all other even numbers are not primes
    if not n & 1: 
        return False
    # range starts with 3 and only needs to go up the squareroot of n
    # for all odd numbers
    for x in range(3, int(n**0.5)+1, 2):
        if n % x == 0:
            return False
    return True
    
   
for i in range(number):
	string_in = raw_input()
	list1 = list(string_in)
	count = Counter(list1)
#	print count
	res = isprime(len(count))
#	print res
	if res == False :
		print "NO"
		
	else :
		flag = 0
		for i in count:
			if isprime(count[i]):
				flag +=1
		if flag == len(count):
			print "YES"
		else :
			print "NO"