def markMult(arr,ind,n):
	i = 2
	num = i*ind
	while (num) <= n:
		arr[num-1] = 1
		i += 1
		num = i*ind
	#return arr

for _ in xrange(int(raw_input())):
	s = str(raw_input())
	sl = list(s)
	d = {}
	k = []
	for j in xrange(len(sl)):
		if sl[j] not in k:
			k.append(sl[j])
			d[sl[j]] = 1
		else:
			d[sl[j]] += 1
	pl = len(k)
	v = d.values()
	primeL = []
	mNum = max(max(v),pl)
	#print mNum
	if mNum >= 2:
		arr = [0]*mNum
		for i in xrange(1,mNum):
			
			if arr[i] == 0:
				#
				primeL.append(i+1)
				markMult(arr,i+1,mNum)
				#print arr
	flag = 0
	for i in xrange(len(v)):
		if v[i] not in primeL:
			print "NO"
			flag = 1
			break
	flag2 = 0
	#print '\n'
	if flag == 0 :
		if pl not in primeL :
			flag2 = 1
			print "NO"
		
	if flag == 0 and flag2 == 0 :
		print "YES"
	
	'''print primeL
	print flag,flag2'''