#include <stddef.h>
#include <iostream>
#include <string>
using namespace std;
int gcd(int a, int b) {
  return (b == 0) ? a : gcd(b, a % b);
}
int main() {
  int n, i, j;
  size_t k;
  string line, a;
  getline(cin, line);
  n = stoi(line);
  while (n--) {
    getline(cin, line);
    a.resize(line.size());
    for (i = 1; i < 26; i++) {
      if (gcd(i, 26) != 1) continue;
      for (j = 1; j < 26; j++) {
        for (k = 0; k < line.size(); k++)
          if (line[k] == ' ') a[k] = ' ';
          else a[k] = (i * (line[k] - 'a') + j) % 26 + 'a';
        if (a.find("this") != string::npos || a.find("that") != string::npos) {
          cout << a << endl;
          goto NEXT;
        }
      }
    }
    NEXT:
    ;
  }
}