import std.stdio;
import std.conv;
import std.string;

void main(){
    foreach(i; 0..readln.chomp.to!int){
        int count;
        bool[string] memo;
        string input = readln.chomp;
        foreach(j; 1..input.length){
            auto current = input;
            if(!(current in memo)){
                ++count;
                memo[current] = true;
            }
            current = (input[0..j] ~ input[j..$].dup.reverse).idup;
            if(!(current in memo)){
                ++count;
                memo[current] = true;
            }
            current = (input[0..j].dup.reverse ~ input[j..$]).idup;
            if(!(current in memo)){
                ++count;
                memo[current] = true;
            }
            current = (input[0..j].dup.reverse ~ input[j..$].dup.reverse).idup;
            if(!(current in memo)){
                ++count;
                memo[current] = true;
            }
            current = input[j..$] ~ input[0..j];
            if(!(current in memo)){
                ++count;
                memo[current] = true;
            }
            current = (input[j..$] ~ input[0..j].dup.reverse).idup;
            if(!(current in memo)){
                ++count;
                memo[current] = true;
            }
            current = (input[j..$].dup.reverse ~ input[0..j]).idup;
            if(!(current in memo)){
                ++count;
                memo[current] = true;
            }
            current = (input[j..$].dup.reverse ~ input[0..j].dup.reverse).idup;
            if(!(current in memo)){
                ++count;
                memo[current] = true;
            }
        }
        count.writeln;
    }
}