#include <iostream>
#include <string>
#include <cstring>
using namespace std;

int main() {
  int b,c, n, l;
  int a[12] = {1,3,5,7,9,11,15,17,19,21,23,25};
  char t[12][26];
  char buf[300];
  bool dec;
  for (int i=0; i<12; i++) {
    for (int j=0; j<26; j++) {
      t[i][(a[i]*j)%26] = j;
    }
  }

  string str, tmp;
  cin >> n;
  while (n--) {
    dec = false;
    do {
      getline(cin, str);
    } while (str == "");
    l = (int)str.size();
    for (int i=0; i<12; i++) {
      for (int j=0; j<26; j++) {
        memcpy(buf, str.c_str(), sizeof(char)*l+1);
        for (int k=0; k<l; k++) {
          if (islower(buf[k])) buf[k] = t[i][(buf[k]-'a'-j+26)%26]+'a';
        }
        tmp.assign(buf);
        if (tmp.find("that")!=string::npos || tmp.find("this")!=string::npos) {
          dec = true;
          break;
        }
      }
      if (dec) break;
    }
    cout << tmp << endl;
  }

  return 0;
}