#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=l;i<r;i++)

int c(const void*x,const void*y){return strcmp((char*)x,(char*)y);}

char s[99];
char ss[600][99];
int main(){
	ll cnt;
	scanf("%lld",&cnt);
	while(cnt--){
		scanf(" %s",s);
		ll n=strlen(s);
		ll cnt=0;
		rep(i,1,n){
			//[0,i),[i,n)に分ける
			char*t=s+i;
			ll x=n-i;
			rep(j,0,i)ss[cnt][j]=s[j    ];rep(j,0,x)ss[cnt][j+i]=t[j    ];ss[cnt][n]=0;cnt++;
			rep(j,0,i)ss[cnt][j]=s[j    ];rep(j,0,x)ss[cnt][j+i]=t[x-1-j];ss[cnt][n]=0;cnt++;
			rep(j,0,i)ss[cnt][j]=s[i-1-j];rep(j,0,x)ss[cnt][j+i]=t[j    ];ss[cnt][n]=0;cnt++;
			rep(j,0,i)ss[cnt][j]=s[i-1-j];rep(j,0,x)ss[cnt][j+i]=t[x-1-j];ss[cnt][n]=0;cnt++;
			rep(j,0,x)ss[cnt][j]=t[j    ];rep(j,0,i)ss[cnt][j+x]=s[j    ];ss[cnt][n]=0;cnt++;
			rep(j,0,x)ss[cnt][j]=t[j    ];rep(j,0,i)ss[cnt][j+x]=s[i-1-j];ss[cnt][n]=0;cnt++;
			rep(j,0,x)ss[cnt][j]=t[x-1-j];rep(j,0,i)ss[cnt][j+x]=s[j    ];ss[cnt][n]=0;cnt++;
			rep(j,0,x)ss[cnt][j]=t[x-1-j];rep(j,0,i)ss[cnt][j+x]=s[i-1-j];ss[cnt][n]=0;cnt++;
		}
		qsort(ss,cnt,99,c);
		ll ans=0;
		rep(i,0,cnt)if(strcmp(ss[i],ss[i+1]))ans++;
		printf("%lld\n",ans);
	}
}
