import std.stdio,std.conv, std.algorithm, std.container,std.array,std.range,std.string,std.typecons;
const dx = [1,0,-1,0];
const dy = [0,1,0,-1];
void read(T...)(auto ref T args){ 
	auto line = readln().split(); 
	foreach(i,ref arg; args) arg = line[i].to!(typeof(arg));
}
int sum(int n){return n * (n + 1)/ 2;}
void main(){
	int m;m.read;
	for(;m>0;m--){
		string cars;cars.read;
		bool[string] exist;
		foreach(i;1..cars.length){
			auto f = (string a) =>[a,a.dup.reverse.idup];
			foreach(c1;f(cars[0..i])) {
				foreach(c2;f(cars[i..$])){
					exist[c1 ~ c2] = true;
					exist[c2 ~ c1] = true;
				}
			}
		}
		exist.length.writeln;
	}
}