m = gets.to_i
for i in 1..m #??????????????????????????¨???
  all = Hash.new(0)
  a = gets.chomp.split("")
  l = a.length()
  for j in 1..(l-1) #????????????????????¨???
    p1 = ""
    p2 = ""
    for k in 0..(j-1) #?????????1
      p1 = p1 + a[k]
    end
    for k in j..(l-1) #?????????2
      p2 = p2 + a[k]
    end
    q1 = p1.reverse
    q2 = p2.reverse
    all[p1+p2] = 1
    all[p1+q2] = 1
    all[q1+p2] = 1
    all[q1+q2] = 1
    all[p2+p1] = 1
    all[p2+q1] = 1
    all[q2+p1] = 1
    all[q2+q1] = 1
  end
  puts all.size
end