#include <stdio.h>
#include <string.h>
#include <stdlib.h>

char str[428][73];
int length;

void copy(char* in, char* out, int length){
	int i;
	for(i=0;i<length;i++){
		out[i]=in[i];
	}
	return;
}

void reverse(char* in, char* out, int length){
	int i;
	for(i=0;i<length;i++){
		out[i]=in[length-1-i];
	}
	return;
}

int comp(const void *c1, const void *c2){
	int d=strcmp((void*)c1,(void*)c2);
	if(d>0){
		return 1;
	}else if(d<0){
		return -1;
	}else{
		return 0;
	}
}

void solve(){
	int i,j;
	for(i=0;i<428;i++){
		for(j=0;j<73;j++){
			str[i][j]=0;
		}
	}

	char line[74];
	scanf("%s",line);
	length=strlen(line);

	copy(line,str[0],length);
	reverse(line,str[1],length);
	int p=2;

	char *A=calloc(length,sizeof(char));
	char *B=calloc(length,sizeof(char));

	for(i=1;i<length;i++){
		copy(&line[0],A,i);
		copy(&line[i],B,length-i);

		//BA
		copy(B,&str[p][0],length-i);
		copy(A,&str[p][length-i],i);
		p++;

		//AB?????¢,AB
		reverse(&str[p-1][0],&str[p][0],length);
		p++;

		//A?????¢,AB
		reverse(A,&str[p][0],i);
		copy(B,&str[p][i],length-i);
		p++;

		//B?????¢,BA
		reverse(&str[p-1][0],&str[p][0],length);
		p++;

		//A?????¢,BA
		copy(B,&str[p][0],length-i);
		reverse(A,&str[p][length-i],i);
		p++;

		//B?????¢,AB
		reverse(&str[p-1][0],&str[p][0],length);
		p++;
	}
	qsort(str,p,sizeof(str[0]),comp);
	int c=0;
	for(i=0;i<p;i++){
		if(strcmp(str[i],str[i+1])) c++;
	}
	printf("%d\n",c);
	free(A);
	free(B);
}

int main(void){
	int m,i;
	scanf("%d",&m);
	for(i=0;i<m;i++){
		solve();
	}
	return 0;
}