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

#define A 12

int main()
{
  int n,i,j;
  int alpha[A]={3,5,7,9,11,13,15,17,19,21,23,25},beta;
  string s,t;
  bool f;
  getline(cin,s);
  while(getline(cin,s)){
    f=true;
    t=s;
    if(t.find("this ",0)==0)f=false;
    if(t.find("that ",0)==0)f=false;
    if(t.find(" this",t.size()-5)==t.size()-5)f=false;
    if(t.find(" that",t.size()-5)==t.size()-5)f=false;
    if(t.find(" this ")!=string::npos)f=false;
    if(t.find(" that ")!=string::npos)f=false;
    for(i=0;f && i<A;i++){
      for(beta=0;f && beta<26;beta++){
	t=s;
	for(j=0;j<t.size();j++){
	  if(t[j]==' ')continue;
	  t[j]-='a';
	  t[j]=(t[j]*alpha[i]+beta)%26;
	  t[j]+='a';
	}
	if(t.find("this ",0)==0)f=false;
	if(t.find("that ",0)==0)f=false;
	if(t.find(" this",t.size()-5)==t.size()-5)f=false;
	if(t.find(" that",t.size()-5)==t.size()-5)f=false;
	if(t.find(" this ")!=string::npos)f=false;
	if(t.find(" that ")!=string::npos)f=false;
      }
    }
    cout<<t<<endl;
  }
}