n = gets.to_i
n.times do
    s = gets.chomp
    a = [s]
    (1..s.size-1).each{|i|
        x, y = s[0..i-1], s[i..-1]
        a << x + y.reverse
        a << x.reverse + y
        a << x.reverse + y.reverse
    }
    p (a + a.map(&:reverse)).uniq.size
end