'''
# 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
import math;
#print 'Hello World!'
def prime(no):
	i=2;
	if(no==1 ):
		return 1;
	
	#print("in l1");
	while(i <=math.sqrt(no)):
		#print("in l1", i, " no:",no);
		if(no%i==0):
			#print("1", i, " no:",no);
			return 1;
		i=i+1;
	return 0;
no=int(raw_input());

while(no >0):
	cnt=0;
	strj=raw_input();
	count = Counter(strj)
	a=len(set(strj));
	if(prime(a)==1):
		print("NO");
	else:
		flag=1;
		for  i in set(strj):
			a=count[i];
			#print("freq: %s and letter %s",a,i);
			if(prime(a)==1):
				print("NO");
				flag=0;
				break;
		#print("cnt :",cnt)
		if(flag==1):
			print("YES");
	no=no-1;