/*
AizuOnline A0022
Maximum Sum Sequence
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int len;
char train[100];
char buf[600][73];
int bptr,blen;

void init()
{
  // strcpy(train,"abcd");
  scanf("%s",train);
}

void print()
{
  int i;
  for(i=0;i<blen;i++)
    printf("%s\n",&(buf[i][0]));
}

int comp (char * s1,char * s2)
{
  return(strcmp(s1,s2));
}
void sort_buf()
{
  qsort(buf,blen,73,(__compar_fn_t)comp);
}

void strncpy_rev(char * d,char * s,size_t n)
{
  int i;

  for(i=0;i<n;i++)
    d[n-1-i]=s[i];
}

int uniq()
{  int i,cnt;
  cnt=1;
  for(i=0;i<blen-1;i++)
    if(0!=strncmp(&(buf[i][0]),&(buf[i+1][0]),len))
      cnt++;
  return(cnt);
}

main()
{ 
  int i,ret,t;
  int N;

  scanf("%d",&N);
  for(t=0;t<N;t++)
  {
 init ();

  bptr=0;

  len = strlen(train);
  //printf("len=%d\n",len);
  for(i=1;i<len;i++)
    {
      strncpy(&(buf[bptr][0]),train,i);
      strncpy(&(buf[bptr][i]),train+i,len-i);
      buf[bptr][len]='\0';
      bptr++;
      strncpy(&(buf[bptr][0]),train+i,len-i);
      strncpy(&(buf[bptr][len-i]),train,i);
      buf[bptr][len]='\0';
      bptr++;

      strncpy_rev(&(buf[bptr][0]),train,i);
      strncpy(&(buf[bptr][i]),train+i,len-i);
      buf[bptr][len]='\0';
      bptr++;
      strncpy_rev(&(buf[bptr][0]),train+i,len-i);
      strncpy(&(buf[bptr][len-i]),train,i);
      buf[bptr][len]='\0';
      bptr++;

      strncpy(&(buf[bptr][0]),train,i);
      strncpy_rev(&(buf[bptr][i]),train+i,len-i);
      buf[bptr][len]='\0';
      bptr++;
      strncpy(&(buf[bptr][0]),train+i,len-i);
      strncpy_rev(&(buf[bptr][len-i]),train,i);
      buf[bptr][len]='\0';
      bptr++;

      strncpy_rev(&(buf[bptr][0]),train,i);
      strncpy_rev(&(buf[bptr][i]),train+i,len-i);
      buf[bptr][len]='\0';
      bptr++;
      strncpy_rev(&(buf[bptr][0]),train+i,len-i);
      strncpy_rev(&(buf[bptr][len-i]),train,i);
      buf[bptr][len]='\0';
      bptr++;
    }
  blen=bptr; // output buffer size

  sort_buf();
  ret=uniq();
  //print();
  printf("%d\n",ret);
}


  return(0);
}