import math

def is_prime(n):
    if n == 2:
        return True
    if n % 2 == 0 or n <= 1:
        return False

    sqr = int(math.sqrt(n)) + 1

    for divisor in range(3, sqr, 2):
        if n % divisor == 0:
            return False
    return True
    
n = int(input())
for _ in range(n):
	li=[0 for i in range(26)]
	s = raw_input()
	for i in range(len(s)):
		li[ord(s[i])-ord('a')]+=1
	flag = True;
	count = 0
	for i in range(26):
		if li[i]>0:
			count+=1
			if not is_prime(li[i]) : flag = False;
			
	if not is_prime(count): flag = False;
	if(flag): print("YES")
	else: print("NO")