process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  var line, lines = chunk.split("\n");
  var i, j, len = lines[0];
  var pro, epi, proRev, epiRev, res, arr;
  for (i = 1; i <= len; i++) {
    line = lines[i];
    arr = [];
    for (j = 0; j < line.length; j++) {
      pro = line.substr(0, j).split('').join('');
      epi = line.substr(j).split('').join('');
      proRev = line.substr(0, j).split('').reverse().join('');
      epiRev = line.substr(j).split('').reverse().join('');
      (res = pro + epi) && arr.indexOf(res) == -1 ? arr.push(res) : '';
      (res = pro + epiRev) && arr.indexOf(res) == -1 ? arr.push(res) : '';
      (res = proRev + epi) && arr.indexOf(res) == -1 ? arr.push(res) : '';
      (res = proRev + epiRev) && arr.indexOf(res) == -1 ? arr.push(res) : '';
      (res = epi + pro) && arr.indexOf(res) == -1 ? arr.push(res) : '';
      (res = epiRev + pro) && arr.indexOf(res) == -1 ? arr.push(res) : '';
      (res = epi + proRev) && arr.indexOf(res) == -1 ? arr.push(res) : '';
      (res = epiRev + proRev) && arr.indexOf(res) == -1 ? arr.push(res) : '';
    }
    console.log(arr.length);
  }
});