#include<stdio.h>
#include<string.h>
#define MAX 73

char train[MAX],first[MAX],last[MAX],firstR[MAX],lastR[MAX],temporary[MAX];
char variation[1000][MAX];
int kind;

void initialize(void)
{
    int i;
    kind=1;

    for(i=0;i<MAX;i++)
    {
        train[i]=0;
        first[i]=0;
        last[i]=0;
        firstR[i]=0;
        lastR[i]=0;
    }
    return;
}

void initialize2(void)
{
    int i;
    for(i=0;i<MAX;i++)
    {
        first[i]=0;
        last[i]=0;
        firstR[i]=0;
        lastR[i]=0;
    }
    return;
}

void check(void)
{
    int i;

    for(i=0;i<kind;i++)
    {
        if(!strcmp(temporary,variation[i]))
        {
            return;
        }
    }
    strcpy(variation[kind],temporary);
    kind++;
    return;
}

void combine(void)
{
    strcpy(temporary,last);
    strcat(temporary,first);
    check();
    strcpy(temporary,first);
    strcat(temporary,lastR);
    check();
    strcpy(temporary,lastR);
    strcat(temporary,first);
    check();
    strcpy(temporary,firstR);
    strcat(temporary,last);
    check();
    strcpy(temporary,last);
    strcat(temporary,firstR);
    check();
    strcpy(temporary,firstR);
    strcat(temporary,lastR);
    check();
    return;
}

void reverse(void)
{
    int i;
    int length=strlen(first)-1;

    for(i=length;i>=0;i--)
    {
        firstR[length-i]=first[i];
    }

    length=strlen(last)-1;

    for(i=length;i>=0;i--)
    {
        lastR[length-i]=last[i];
    }
    return;
}

void devide(int num)
{
    int i,j,k;

    for(i=0;i<num-1;i++)
    {
        initialize2();
        for(j=0;j<=i;j++)
        {
            first[j]=train[j];
        }
        for(j=i+1;j<num;j++)
        {
            last[j-i-1]=train[j];
        }
        reverse();
        combine();
    }

    return;
}

int main(void)
{
    int m,i;

    scanf("%d",&m);

    for(i=0;i<m;i++)
    {
        int j;
        initialize();
        scanf("%s",train);
        strcpy(variation[0],train);
        devide(strlen(train));
        printf("%d\n",kind);
    }

    /*for(i=0;i<kind;i++)
    {
        printf("%d:%s\n",i,variation[i]);
    }*/

    return 0;
}