#include <algorithm>
#include <string>
#include <set>
#include <iostream>
using namespace std;

int M;
string S;

int main( void ) {
	
	cin >> M;
	
	while ( M-- ) {
		
		cin >> S;
		
		typedef set<string> set_t;
		set_t all;
		all.insert( S );
		
		for ( size_t i = 1; i < S.size(); i++ ) {
			
			string L = S;
			L.resize( i );
			string R = S.substr( i );
			
			string L2 = L, R2 = R;
			reverse( L2.begin(), L2.end() );
			reverse( R2.begin(), R2.end() );
			
			all.insert( R + L );
			all.insert( R + L2 );
			all.insert( R2 + L );
			all.insert( R2 + L2 );
			all.insert( L + R );
			all.insert( L + R2 );
			all.insert( L2 + R );
			all.insert( L2 + R2 );
			
		}
		
		cout << all.size() << endl;
		
	}
	
	return 0;
	
}