T = int(raw_input())

def isPrime(num):
	if num == 1:
		return False
	for i in range(2,num):
		if num % i == 0:
			return False
	return True
		

for item in range(T):
	data = raw_input()
	lst = {}
	for i in data:
		if i not in lst:
			lst[i] = 1
		else:
			lst[i] += 1
	
	if isPrime(len(lst)):
		for i in lst:
			if not isPrime(lst[i]):
				print "NO"
				break
		else:
			print "YES"
	else:
		print "NO"