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

vector<string> split(string s) {
  s += " ";
  vector<string> res;
  string str;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == ' ') {
      res.push_back(str);
      str = "";
    } else {
      str += s[i];
    }
  }

  return res;
}

vector<int> convert(int a, int b) {
  vector<int> res(26);
  for (int i = 0; i < 26; ++i) {
    res[i] = (a * i + b) % 26;
  }

  return res;
}

vector<string> calc(const vector<string> &v, const vector<int> &t) {
  vector<string> res;
  for (string s : v) {
    for (int i = 0; i < s.size(); ++i) {
      s[i] = (t[s[i] - 'a'] + 'a');
    }
    res.push_back(s);
  }

  return res;
}

void solver() {
  string s;
  getline(cin, s);
  vector<string> v = split(s);

  for (int i = 1; i < 26; ++i) {
    if (__gcd(i, 26) - 1) continue;
    for (int j = 0; j < 26; ++j) {
      vector<int> table = convert(i, j);
      vector<string> res = calc(v, table);

      bool f = false;
      for (string u : res) {
        if (u == "that" || u == "this") {
          f = true;
        }
      }

      if (f) {
        for (int k = 0; k < res.size(); ++k) {
          cout << res[k] << (k + 1 == res.size() ? "\n" : " ");
        }
        return;
      }
    }
  }
}

int main() {
  int n;
  cin >> n;
  cin.ignore();

  for (int i = 0; i < n; ++i) {
    solver();
  }
}