#include<iostream>
#include<string>
using namespace std;
int main(){
  int n,a[12] = {1,3,5,7,9,11,15,17,19,21,23,25};
  cin >>n;
  cin.ignore();
  while(n--){
    string s;
    getline(cin,s);
    for(int i=0; i<12; i++){
      for(int j=0; j<26; j++){
	string f = s;
	for(int k=0; k<s.size(); k++){
	  if(f[k] >= 'a' && f[k] <= 'z'){f[k] = (a[i]*(f[k]-'a')+j)%26+'a';}
	}
	string::size_type pos_this = f.find("this");
	string::size_type pos_that = f.find("that");
	if(pos_this != string::npos){cout <<f<<endl;}
	if(pos_that != string::npos){cout <<f<<endl;}
      }
    }
  }
  return 0;
}