'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
#print 'Hello World!'
from collections import Counter
def prime(n):
	c=0
	if n==1 or n==0:
		return 0
	for i in range(2,n):
		if n%i==0:
			return 0
		c+=1
	else :
		return 1
t=int(raw_input())
while t>0:
	t-=1
	s=raw_input()
	s=list(s)
	c=Counter(s)
	m=0
	for key in c:
		m+=prime(c[key])
	if m==len(c) and prime(m)==1:
		print"YES"
	else:
		print"NO"