#include <bits/stdc++.h>

using namespace std;

string shift(string s, int a, int b) {
  for (int i = 0; i < s.size(); i++) {
    if (s[i] < 'a' || 'z' < s[i]) continue;
    s[i] = (a * (s[i] - 'a') + b) % 26 + 'a';
  }
  return s;
}

void solve(string s) {
  for (int i = 0; i < 26; i++) {
    if (i % 2 == 0 || i == 13) continue;
    for (int j = 0; j < 26; j++) {
      string w = shift(s, i, j);
      if (w.find("that") != string::npos || w.find("this") != string::npos) {
        cout << w << endl;
        i = j = 26;
      }
    }
  }
}

int main(void) {
  int n;
  cin >> n;

  cin.ignore();
  for (int i = 0; i < n; i++) {
    string s;
    getline(cin, s);
    solve(s);
  }

  return 0;
}
