#include<iostream>
#include<string>
#include<cctype>
using namespace std;
#define NON string::npos
int main(){
  int n;
  (cin >> n).ignore();
  while(n--){
    string str;
    getline( cin, str);
    for(int i = 0 ; i < 26 ; i++ ){
      for(int j = 0 ; j < 26 ; j++ ){
        string ret = str;
        for(int k = 0 ; k < ret.size() ; k++ ){
          if(islower(ret[k])) ret[k] = ((ret[k] - 'a') * i + j) % 26 + 'a';
        }
        if(ret.find("that") != NON || ret.find("this") != NON){
          cout << ret << endl;
          i = j = 27;
        }
      }
    }
  }
}