require 'set'

n = gets.to_i
n.times do
  s = gets.chomp

  set = Set.new
  (1..s.length-1).each do |i|
    p0, p1 = s[0...i], s[i...s.length]

    set << "#{p0}#{p1}" \
        << "#{p0}#{p1.reverse}" \
        << "#{p0.reverse}#{p1}" \
        << "#{p0.reverse}#{p1.reverse}" \
        << "#{p1}#{p0}" \
        << "#{p1}#{p0.reverse}" \
        << "#{p1.reverse}#{p0}" \
        << "#{p1.reverse}#{p0.reverse}"
  end

  puts set.length
end