require 'set'

n = gets.to_i

n.times do
  s = gets.chomp
  ans = Set.new
  ans << s
  (1..s.size-1).each do |i|
    ox, oy = s[0...i], s[i..-1]
    rx, ry = ox.reverse, oy.reverse
    ans << ox + oy << rx + oy << ox + ry << rx + ry <<
           oy + ox << oy + rx << ry + ox << ry + rx
  end
  puts ans.size
end
