#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
 int n,s,sv1=0,sv=0;

 
 cin >> n; 
 
 set<string> v1;
 vector<int> v2(n);
 int i;
 for(i=0;i<n;i++){
  string tmp,tmp2,t1,t2;
  cin >> tmp;
  s = tmp.size();
  for(int j=1;j<s;j++){
    
   t1 = tmp.substr(0,j);
   t2 = tmp.substr(j);
   tmp2 = t1.append(t2);
   v1.insert(tmp2);
   
   t1 = tmp.substr(0,j);
   t2 = tmp.substr(j);
   tmp2 = t2.append(t1);
   v1.insert(tmp2);
  

   t1 = tmp.substr(0,j);
   t2 = tmp.substr(j);
   reverse(t1.begin(), t1.end()); //t1は逆順
   tmp2 = t1.append(t2);
   v1.insert(tmp2);

   t1 = tmp.substr(0,j);
   t2 = tmp.substr(j);
   reverse(t1.begin(), t1.end()); 
   tmp2 = t2.append(t1);
   v1.insert(tmp2);

 
   t1 = tmp.substr(0,j);
   t2 = tmp.substr(j);
   reverse(t2.begin(), t2.end()); //t2は逆順
   tmp2 = t1.append(t2);
   v1.insert(tmp2);

   t1 = tmp.substr(0,j);
   t2 = tmp.substr(j);
   reverse(t2.begin(), t2.end());
   tmp2 = t2.append(t1);
   v1.insert(tmp2);
  
   
   t1 = tmp.substr(0,j);
   t2 = tmp.substr(j);
   reverse(t1.begin(), t1.end()); //t1は逆順
   reverse(t2.begin(), t2.end());
   tmp2 = t1.append(t2);
   v1.insert(tmp2);

   t1 = tmp.substr(0,j);
   t2 = tmp.substr(j);
   reverse(t1.begin(), t1.end()); //t1は逆順
   reverse(t2.begin(), t2.end());
   tmp2 = t2.append(t1);
   v1.insert(tmp2);

  }
  sv1 = v1.size() - sv;
  v2[i] = sv1;
  sv = v1.size();
  
 }
 //set<string>::iterator p;
 //for(p=v1.begin();p!=v1.end();p++)
 //cout << *p << endl;

 for(i=0;i<n;i++){
  cout << v2[i] << endl;
 }
 return 0;
}