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