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