import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

const real eps = 1e-10;

void main(){
	auto m = readInt();
	for(int i; i < m; ++i) {
		bool hash[string];
		auto s = readln.chomp;
		for(int j = 1; j < s.length; ++j) {
			auto s1 = s[0..j];
			auto s2 = s[j..$];
			auto s1r = s1.dup.reverse.idup;
			auto s2r = s2.dup.reverse.idup;
			hash[s1 ~ s2] = true;
			hash[s1 ~ s2r] = true;
			hash[s1r ~ s2] = true;
			hash[s1r ~ s2r] = true;
			hash[s2 ~ s1] = true;
			hash[s2 ~ s1r] = true;
			hash[s2r ~ s1] = true;
			hash[s2r ~ s1r] = true;
		}
		writeln(hash.length);
	}
}