require 'set'

def run(s)
  ans=[]
  for i in 0..s.size-2
    l1=s[0..i]
    r1=s[i+1..-1]
    l2=l1.reverse
    r2=r1.reverse
    ans.push(l1+r1)
    ans.push(l1+r2)
    ans.push(l2+r1)
    ans.push(l2+r2)
  end
  return ans
end

m=gets.to_i
for i in 0..m-1
  s=gets.chomp
  s2=s.reverse
  a=run(s)
  b=run(s2)
  set=Set.new(a+b)
  puts set.size
end