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

#define LEN 120

void roop(char str[LEN]);
int judge1(char str1[LEN], char str2[LEN], char str0[LEN], int num);
void change(char *str);

int main(void)
{
	char str[LEN][LEN];
	int m;
	int k, i;
	int sum = 0;
	int flag;
	
	scanf("%d", &m);
	
	for(k = 0; k < m; k++){
		scanf("%s", str[k]);
	}
	
	for(k = 0; k < m; k++){
		roop(str[k]);
	}
	
	return 0;
}

void roop(char str[LEN])
{
	int k, i, j;
	int sum = 0;
	char str1[LEN], str2[LEN], str0[LEN][LEN];
	int num = 0;
	int flag;
	
	for(k = 0; str[k + 1] != '\0'; k++){
		strncpy(str1, str, k + 1);
		str1[k + 1] = '\0';
		
		j = 0;
		for(i = k + 1; str[i] != '\0'; i++){
			str2[j] = str[i];
			j++;
		}
		str2[j] = '\0';
		
		num = judge1(str1, str2, str0[num], num);
		num = judge1(str2, str1, str0[num], num);
		change(str2);
		
		num = judge1(str1, str2, str0[num], num); // str2のみ反転が継続
		num = judge1(str2, str1, str0[num], num);
		change(str1);
		
		num = judge1(str1, str2, str0[num], num); //str1も反転が継続
		num = judge1(str2, str1, str0[num], num);
		change(str2);
		
		num = judge1(str1, str2, str0[num], num); //str2をもとに戻す
		num = judge1(str2, str1, str0[num], num);
	}
	
	for(k = 0; k < num; k++){
		flag = 0;
		for(i = 0; i < k; i++){
			if(strcmp(str0[k], str0[i]) == 0){
				flag = 1;
			}
		}
		if(flag == 0) sum++;
	}
	printf("%d\n", sum);
}

int judge1(char str1[LEN], char str2[LEN], char str0[LEN], int num)
{
	strcpy(str0, str1);
	strcat(str0, str2);
	
	return ++num;
}

void change(char *str)
{
	char tmp;
	char *str1 = str;
	
	while(*(++str1) != '\0'){}
	str1--;
	
	while(str < str1){
		tmp = *str;
		*str = *str1;
		*str1 = tmp;
		str++;
		str1--;
	}
	
}
