def split(line)
  idx = 1
  out = []
  while idx < line.size
    head = line[0,idx]
    tail = line[idx, line.size - idx]
    out.push([head, tail])
    idx += 1
  end
  return out
end


def compute(line)
  answers = {}
  splitted = split(line)
  splitted.each { |head, tail|
    #puts "#{head}|#{tail}"
    answers[ head + tail ] = 1
    answers[ head.reverse + tail ] = 1
    answers[ head + tail.reverse ] = 1
    answers[ head.reverse + tail.reverse ] = 1
    answers[ tail + head ] = 1
    answers[ tail.reverse + head ] = 1
    answers[ tail + head.reverse ] = 1
    answers[ tail.reverse + head.reverse ] = 1
  }
  #p answers
  puts answers.keys.size
end

num = gets.to_i
while line = gets
  compute(line.chomp)
end