#include<algorithm>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int gcd(int p,int q){
  int s;
  while(q){
    p%=q;
    s=p;
    p=q;
    q=s;
  }
  return p;
}
int main(){
  int i,j;
  int a,b,n;
  int ln;
  string s,t;
  cin>>n;
  getline(cin,s);
  for(i=0;i<n;i++){
    getline(cin,s);
    ln=s.length();
    for(a=1;a<26;a++){
      if(gcd(26,a)==1){
	for(b=0;b<26;b++){
	  t="";
	  for(j=0;j<ln;j++){
	    if('a'<=s[j]&&s[j]<='z')
	      t+=(a*(s[j]-'a')+b)%26+'a';
	    else
	      t+=s[j];
	  }
	  if(t.find("that")!=string::npos||t.find("this")!=string::npos)
	    break;
	}
	if(b!=26)
	  break;
      }
    }
    cout<<t<<endl;
  }
  return 0;
}