from math import *
testcase=raw_input()
testcase=int(testcase);
def isprime(number):
    if number==0 or number==1:
      return 0;
    else:
      for i in range (2,number):
       if ( number % i == 0 and i != number ):
         return 0;
      return 1;
while (testcase>0):
	string=raw_input()
	count=[];
	discount=0;
	flag=1;
	for i in range(0,26):
		count.append(0);
	for i in range(0,len(string)):
		var=ord(string[i])-97;
		count[var]=count[var]+1;
	for i in range(0,26):
		if count[i]!=0:
			discount=discount+1;
			if (isprime(count[i])==0):
				flag=0;
				break;
	if (flag and isprime(discount)):
		print "YES"
	else:
		print "NO"
	testcase=testcase-1;