def isprime(n):
    n = abs(int(n))
    if n < 2:
        return False
    if n == 2: 
        return True   
    if not n & 1: 
        return False
    for x in range(3, int(n**0.5) + 1, 2):
        if n % x == 0:
            return False

    return True
t=input()
for i in range(t):
	s=raw_input()
	l=list()
	for j in s:
		l.append(j)
	d=dict()
	for k in l:
		d[k]=d.get(k,0)+1
	m=len(d)
	if(isprime(m)):
		flag=0
		for a,b in d.items():
			g=isprime(b)
			if(g==False):
				flag=1
				break
		if flag==0:
			print 'YES'
		else:
			print 'NO'
	else:
		print 'NO'