#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int main(void) { int m; scanf( "%d", &m ); for( int c = 0; c < m; c ++ ){ set buf; char str[1024]; scanf( "%s", str ); int len = strlen( str ); for( int d = 1; d <= len - 1; d ++ ){ char result[1024]; char a[1024], b[1024], ar[1024], br[1024]; memcpy( a, str, d ); memcpy( b, str + d, len - d ); for( int t = 0; t < d; t ++ ) ar[t] = str[d-1-t]; for( int t = 0; t < len - d; t ++ ) br[t] = str[len-1-t]; a[d] = ar[d] = b[len-d] = br[len-d] = 0; string s; s = a; s += b; buf.insert( s ); s = a; s += br; buf.insert( s ); s = ar; s += b; buf.insert( s ); s = ar; s += br; buf.insert( s ); s = b; s += a; buf.insert( s ); s = b; s += ar; buf.insert( s ); s = br; s += a; buf.insert( s ); s = br; s += ar; buf.insert( s ); } printf( "%d\n", buf.size() ); } return 0; }