#include <iostream>
#include <string>
using namespace std;

int code[26];

int gcd(int x, int y){
  if(y == 0) return x;
  return gcd(y, x % y);
}

int affine(int m, int a, int b){
  return (m * a + b) % 26;
}

int main(void){
  int n;
  string p;
  cin >> n; cin.ignore();
  while(n--){
    getline(cin, p);
    bool finded = false;
    for(int a = 1; a < 26; a++){
      if(finded) break;
      if(gcd(a, 26) != 1) continue;

      for(int b = 1; b < 26; b++){
        for(int i = 0; i < 26; i++){
          code[affine(i, a, b)] = i;
        }

        string c = "";
        for(int i = 0; i < p.size(); i++){
          if(p[i] == ' ') c += " ";
          else c += (char)(code[p[i] - 'a'] + 'a');
        }

        bool tis = c.find("this", 0) != string::npos;
        bool tht = c.find("that", 0) != string::npos;
        if(tis || tht){
          cout << c << endl;
          finded = true;
          break;
        }
      }
    }
  }
  return 0;
}