/**
 *  Organize Your Train part II (PKU 3007)
 *  by Kenji Inoue, 2007-01-03
 **/

#include <iostream>
#include <string>
#include <set>

using namespace std;

#define rev(s) (string((s).rbegin(), (s).rend()))

int main() {
  int N;
  cin >> N;
  while (N--) {
    string str;
    cin >> str;

    set<string> bag;
    for (int i=1; i<str.size(); i++) {
      string head = str.substr(0, i);
      string tail = str.substr(i);

      for (int j=0; j<2; j++) {
        bag.insert(head + tail);
        bag.insert(rev(head) + tail);
        bag.insert(head + rev(tail));
        bag.insert(rev(head) + rev(tail));
        if (j == 0) { swap(head, tail); }
      }
    }
    cout << bag.size() << endl;
  }

  return 0;
}
