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

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

int main(void){
  int n;
  string c, p;
  cin >> n; cin.ignore();
  
  while(n--){
    getline(cin, c); p = c;
    for(int a = 1; a < 100; a++){
      for(int b = 1; b < 26; b++){
        for(int i = 0; i < p.size(); i++){
          if(c[i] != ' ') p[i] = (char)(affine(c[i] - 'a', a, b) + 'a');
        }
        
        if(p.find("this") != string::npos || p.find("that") != string::npos){
          cout << p << endl;
          break;
        }
      }
    }
  }
  return 0;
}