#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
  int n;
  cin >> n;
  getchar();
  for(int i = 0; i < n; i++){
    string s,ss;
    getline(cin,s);
    bool f = true;
    for(int a = 0; f; a++){
      for(int b = 0; b < 26; b++){
	ss = s;
	for(int j = 0; j < (int)s.size(); j++){
	  if(s[j] != ' '){
	    ss[j] = ((s[j]-'a') * a + b) % 26 + 'a';
	  }
	}
	if((int)ss.find("this") != -1 || (int)ss.find("that") != -1){
	  f = false;
	  break;
	}
      }
    }
    cout << ss << endl;
  }
}