#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef vector<int> vi;
#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(c) int((c).size())

vi stovi(const string& s)
{
  vi v;
  tr (s, i) {
    v.pb(*i-'a');
  }
  return v;
}

string vitos(const vi& v)
{
  string s;
  tr (v, i) {
    s.pb('a'+*i);
  }
  return s;
}

void encode(int a, int b, const vi& from, vi& to)
{
  for (int i = 0; i < sz(to); i++) {
    if (0 <= from[i] && from[i] <= 25)
      to[i] = (a * from[i] + b) % 26;
    else
      to[i] = from[i];
  }
}

string code_break(const string& s)
{
  vi v = stovi(s);
  vi tmp = vi(sz(v));
  for (int a = 3; ; a++) {
    if ((a % 2) == 0 || (a % 13) == 0)
      continue;
    for (int b = 0; b < 25; b++) {
      encode(a, b, v, tmp);
      string s = vitos(tmp);
      if ((int)s.find("this ") >= 0
          || (int)s.find("that ") >= 0
          || (int)s.find(" this") >= 0
          || (int)s.find(" that") >= 0) {
        return s;
      }
    }
  }
}

int main(int argc, char **argv)
{
  int n;
  string s;
  cin >> n;
  getline(cin, s);
  while (n--) {
    getline(cin, s);
    cout << code_break(s) << endl;
  }
  return 0;
}