def eratosthenes2(n):
    multiples = set()
    listn=[]
    for i in range(2, n+1):
        if i not in multiples:
            listn.append(i)
            multiples.update(range(i*i, n+1, i))
    return listn
listn=[]    
listn = eratosthenes2(100000)
some_set=set(listn)
x = int(raw_input())
some_array = []
while(x>0):
	some_array.append(raw_input())
	x-=1
some_dict = {}
alphabet = 'abcdefghijklmnopqrstuvwxyz'
for i in range(len(list(alphabet))):
	some_dict[alphabet[i]] = 0
for string in some_array:
	x = set(list(string)) #use the length of the string to run siev
	if len(x) in some_set:
		flag = True
		for str in string:
			some_dict[str] += 1
		for key,value in some_dict.items():
			if value!=0 and value not in some_set: 
				flag = False
		for i in range(len(list(alphabet))):
			some_dict[alphabet[i]] = 0
		if flag == False:
			print "NO"
		else:
			print "YES"
	else:
		print "NO"