from collections import OrderedDict
for i in range(input()):
    a=raw_input()
    b=''.join(OrderedDict.fromkeys(a))
    c=len(b)
    f1=0
    f2=0
    if c==1:
        f1=1
    else:
        for i in range(2,int(c**0.5)+1):
            if c%i==0:
                f1=1
                break
        for j in range(c):
            x=a.count(b[j])
            if x==1:
                f2=1
                break
            else:
                for k in range(2,int(x**0.5)+1):
                    if x%k==0:
                        f2=1
    if f1==0 and f2==0:
        print "YES"
    else:
        print "NO"