def is_prime(n):
    for i in range(3, n):
        if n % i == 0:
            return False
    if n==1 or n==4:
    	return False
    return True	
t = int(raw_input())
while t>0:
	n = raw_input()
	list = [ord(i)-97 for i in n]
	t = t-1
	a=[0]*26
	for i in list:
		a[i]=a[i]+1
	x = 0
	m = 0
	for i in a:
		if i!=0:
			x=x+1
			if is_prime(i)!=True:
				break
	else:
		m = 1
	if is_prime(x) and m==1:
		print "YES"
	else:
		print "NO"