object Main {
  def setTrain(t1: String, t2: String): List[String] = {
    (for(x <- List(t1, t1.reverse); y <- List(t2, t2.reverse)) yield {
      List(List(x, y), List(y, x)).map(_.mkString)
    }).flatten
  }

  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    for(_ <- 1 to n) {
      val s = sc.next
      val set = scala.collection.mutable.ArrayBuffer.empty[String] 
      for(len <- 1 to s.length - 1) {
        val t1 = s.take(len)
        val t2 = s.drop(len)
        setTrain(t1, t2).foreach(t =>
          if (!set.contains(t)) set += t)
      }
      println(set.size)
    }
  }
}