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

int gcd(int a, int b) {
  return b == 0 ? a : gcd(b, a%b);
}

int main() {
  string line;
  int Tc;
  cin >> Tc;
  cin.ignore();
  while(Tc--) {
    getline(cin, line);
    for(int a = 1; a < 26; ++a) {
      for(int b = 0; b < 26; ++b) {
	if(gcd(a, 26) != 1) continue;
	string t = line;
	for(int i = 0; i < t.size(); ++i) {
	  if(isalpha(t[i])) {
	    int r = t[i] - 'a';
	    t[i] = (a*r+b)%26+'a';
	  }
	}
	if(t.find("that") != string::npos ||
	   t.find("this") != string::npos) {
	  cout << t << endl;
	  a = b = (1<<28);
	  break;
	}
      }
    }
  }
  return 0;
}