#include<iostream>
using namespace std;
int mod[]={1,3,5,7,9,11,15,17,19,21,23,25};
int main(){
  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] = 'a'+((s[k]-'a')*mod[i]+j)%26;
	}
	if(t.find("this") != string::npos){cout <<t<<endl;goto flag;}
	if(t.find("that") != string::npos){cout <<t<<endl;goto flag;}
      }
    }
  flag:;
  }
  return 0;
}