def sol( s )
	l = s.length
	a = Array.new
	for i in 1..i
		s1 = a[0, i]
		s2 = a[i..(l-1)]
		a.push( s1 + s2 )
		a.push( s2 + s1 )
		a.push( s1.reverse + s2 )
		a.push( s2 + s1.reverse )
		a.push( s1 + s2.reverse )
		a.push( s2.reverse + s1 )
		a.push( s1.reverse + s2.reverse )
		a.push( s2.reverse + s1.reverse )
	end
	a.uniq.size
end

m = gets.chomp.to_i
m.times do
	s = gets.chomp
	puts sol( s )
end