prime={}
for i in range(0,100001):
	prime.update({i:0})
prime.update({0:1})
prime.update({1:1})

for i in range(4,100004,2):
	prime.update({i:1})
for i in range(3,100004,2):
	if i*i>100004:
		break
	if (prime[i])==0:
		for j in range(2,100004,1):
			if i*j>100004:
				break
			prime[i*j]=1
t=int(raw_input())
for i in range(t):
	mp={};
	k=0
	for j in range(26):
		mp[j]=0
	str=raw_input()
	l=len(str)
	for j in range(l):
		p=ord(str[j])-97
		if mp[p] == 0:
			k+=1
		mp[p]+=1
	#print "e"
	if prime[k]==0:
		counter=0
		#print "hello"
		for j in range(26):
			if mp[j] !=0:
				if prime[mp[j]]==0:
					continue
				else:
					counter=1
					break
		if counter==0:
			print "YES"
		else:
			print "NO"
	else:
		print "NO"