m = gets.to_i

m.times do
  cars = gets.strip
  #p cars

 
  finals = {}
  ncars = cars.length

  for k in (1...ncars)
    cars0 = cars[0, k]
    cars1 = cars[k, ncars - k]
    # p [cars0, cars1]

    rcars0 = cars0.reverse
    rcars1 = cars1.reverse

    finals[ cars0 +  cars1] = 1
    finals[rcars0 +  cars1] = 1
    finals[ cars0 + rcars1] = 1
    finals[rcars0 + rcars1] = 1
    finals[ cars1 +  cars0] = 1
    finals[rcars1 +  cars0] = 1
    finals[ cars1 + rcars0] = 1
    finals[rcars1 + rcars0] = 1
  end

  puts finals.keys.length
end

