noprimes = set(j for i in range(2, 316) for j in range(i*2 ,100000, i))
primes = [x for x in range(2, 100000) if x not in noprimes]

for _ in range(int(raw_input())):
	list1 = list(raw_input())
	set1 = set(list1)
	flag = 0
	if (len(set1) not in primes):
		flag = 1
	else:
		for c in set1:
			if(list1.count(c) not in primes):
				flag = 1
	if flag == 0:
		print "YES"
	else:
		print "NO"