import collections

def is_prime(n):
	if n <= 1:
		return 0
	i = 2
	while i*i <= n:
		if n % i == 0:
			return 0
		i += 1
	return 1

t = int(raw_input())
for i in range(t):
	a = raw_input()
	
	n = len(set(a))
	if is_prime(n) == 0:
		print "NO"
		continue
	
	d = collections.defaultdict(int)
	for c in a:
		d[c] += 1
	
	flag = True
	for c in d:
		if is_prime(d[c]) == 0:
			flag = False
	if flag:
		print "YES"
	else:
		print "NO"