import math
for i in range(input()):
	l=[]
	a=raw_input()
	d=0
	e=0
	freq=[0 for _ in range(26)]
	for c in a:
		freq[ord(c)-ord('a')]+=1
	for j in range(0,len(a)):
		if(a[j] not in l):
			l.append(a[j])
	h=len(l)
	if(len(l)==1):
		d+=1
	for k in range(2,int(math.sqrt(h))+1):
		if(h%k==0):
			d+=1
	for m in range(0,len(freq)):
		if(freq[m]!=0):
			if(freq[m]==1):
				e+=1
			else:
				for n in range(2,int(math.sqrt(freq[m]))+1):
					if(freq[m]%n==0):
						e+=1
	if(d>0 or e>0):
		print("NO")
	else:
		print("YES")