def is_Prime(n):
    if n==2 or n==3: return True
    if n%2==0 or n<2: return False
    for i in range(3,int(n**0.5)+1,2):   # only odd numbers
        if n%i==0:
            return False

    return True
def get_input():
    case = input()
    if case in range(1,11):
        for i in range(case):
            decide = True
            string = raw_input()
            string = list(string)
            set_string = list(set(string))
            dist_alpha = is_Prime(len(set_string))
            for a in set_string:
                var = is_Prime(string.count(a))
                decide = dist_alpha and decide and var
            if decide:
                print "YES"
            else:
                print "NO"
    else:
        exit
get_input()