#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  cin.ignore();
  vector<string> s(n);
  for (int i = 0; i < n; ++i) {
    getline(cin, s[i]);
  }

  for (int i = 0; i < n; ++i) {
    for (int a = 0; a < 26; ++a) {
      for (int b = 0; b < 26; ++b) {
        string s2 = s[i];
        for (int j = 0; j < s2.size(); ++j) {
          if (s2[j] == ' ') {
            continue;
          }
          s2[j] = (a * (s2[j] - 'a') + b) % 26 + 'a';
        }

        if (s2.find("this") != s2.npos || s2.find("that") != s2.npos) {
          s[i] = s2;
        }
      }
    }
  }

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

