#include<iostream>
#include<string>
#include<algorithm>
#include<map>

using namespace std;


int main(){
  int n;
  string s;
  map<string,bool> Ans;
  cin >> n;
  while(n-- > 0){
    cin >> s;
    string s1,s2;
    for(int i=1;i<s.length();i++){
      s1 = s.substr(0,i);
      s2 = s.substr(i,s.length()-i);
      Ans[s1+s2] = true;
      Ans[s2+s1] = true;
      reverse(s1.begin(),s1.end());
      Ans[s1+s2] = true;
      Ans[s2+s1] = true;
      reverse(s1.begin(),s1.end());
      reverse(s2.begin(),s2.end());
      Ans[s1+s2] = true;
      Ans[s2+s1] = true;
      reverse(s1.begin(),s1.end());
      Ans[s1+s2] = true;
      Ans[s2+s1] = true;
    }
    cout << Ans.size() << endl;
    Ans.clear();
  }

  return 0;
}