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

int L, count;
char str[100];
char ans[1000][100];

int judge(char *s){
	int i;
	for(i = 0; i < count; i++){
		if(strcmp(ans[i], s) == 0) return 0;
	}
	return 1;
}

void reverse(char *med, char *s){
	int i;
	for (i = 0; i < strlen(s); i++)
	{
		med[i] = s[strlen(s)-1-i];
	}
	med[i] = '\0';
	return;
}

int main()
{
	int i, k;
	char a[100], b[100], c[100], d[100], e[100], f[100];
	scanf("%d", &L);
	for (k = 0; k < L; k++)
	{
		count = 1;
		scanf("%s", str);
		strcpy(ans[0], str);
		reverse(c, str);
		if(judge(c)){
			strcpy(ans[count], c);
			count++;
		}
		for (i = 1; i < strlen(str); i++)//i??????????????§??????
		{
			strcpy(a, "\0");
			strcpy(b, "\0");
			strncat(a, str, i);
			strcat(b, &str[i]);
			reverse(c, a);
			strcat(c, b);
			if(judge(c)){
				strcpy(ans[count], c);
				count++;
			}
			reverse(d, c);
			if(judge(d)){
				strcpy(ans[count], d);
				count++;
			}

			strcpy(d, "\0");
			reverse(c, b);
			strcat(d, a);
			strcat(d, c);
			if(judge(d)){
				strcpy(ans[count], d);
				count++;
			}
			reverse(e, d);
			if(judge(e)){
				strcpy(ans[count], e);
				count++;
			}

			strcpy(e, "\0");
			reverse(c, a);
			reverse(d, b);
			strcat(e, c);
			strcat(e, d);
			if(judge(e)){
				strcpy(ans[count], e);
				count++;
			}
			reverse(f, e);
			if(judge(f)){
				strcpy(ans[count], f);
				count++;
			}
		}
		printf("%d\n", count);
	}
	return 0;
}