def prime(a):
	if a==1:
		return False
	for i in range(2,a/2+1):
		if a%i==0:
			return False
	return True

t = input()
while t:
	s = raw_input()
	l = len(s)
	freq = {}
	for i in range(l):
		if s[i] not in freq.keys():
			if 'dis' not in freq.keys():
				freq['dis']=1
			else:
				freq['dis']+=1
			freq[s[i]]=1
		else:
			freq[s[i]]+=1
	flag=1
	for i in freq.keys():
		if not prime(freq[i]):
			flag=0
			break
	if not prime(freq['dis']):
		flag=0
	if flag==1:
		print "YES"
	else:
		print "NO"
	t-=1