def is_prime(n):
  if n < 2:
    return False
  for d in range(2, n/2 + 1):
    if n%d == 0:
      return False
  return True

def main():
  t = int(raw_input())
  for i in range(t):
    count_list = [0 for i in range(0, 26)]
    s = raw_input()
    for c in s:
      count_list[ord(c) - ord('a')] += 1
    count_list = [e for e in count_list if e != 0]
    if not is_prime(len(count_list)):
      print "NO"
    else:
      flag = False
      for count in count_list:
        if not is_prime(count):
          print "NO"
          flag = True
          break

      if not flag:
        print "YES"

if __name__ == "__main__":
  main()