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

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

T=input()

def isPrime(n):
	if n==2:
		return True
	elif n==1:
		return False
	for i in range(2,n):
		x=n % i
		if x == 0:
			return False
		else:
			continue
	return True

def cnt_alpha(s):
	n=len(''.join(set(s)))
	if isPrime(n):
		return True
	return False
	
def cnt_freq(s):
	freq=Counter(s)
	l1=freq.values()
	for i in range(0,len(l1)):
		if isPrime(l1[i]):
			continue
		else:
			return False
	return True

while T:
	str1=raw_input()
	#s_list=[]
	#s_list=list(str1)
	if cnt_alpha(str1) and cnt_freq(str1):
		print "YES"
	else:
		print "NO"
	T=T-1