m = gets.to_i
m.times do |i|
  res = []
  s = gets.chomp
  for j in (0...s.size) do
    l = s[0...j]
    r = s[j...s.size]
    revl = l.reverse
    revr = r.reverse
    res << revl + r
    res << l + revr
    res << revl + revr
    res << r + l  
    res << revr + l  
    res << r + revl  
    res << revr + revl  
  end
  p res.uniq.size
end