#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
using namespace std;

vector<int> a;
vector<int> b;
int id=2;
int N;
int yukuri(int n,int m){
  if(n<m) swap(n,m);
  while(m>0){
    int tmp = n%m;
    n=m;
    m=tmp;
  }
  return n;
}

void add_ab(){
  ++id;
  while(yukuri(id,26)!=1) id++;
  for(int i=0;i<26;i++){
    a.push_back(id);
    b.push_back(i);
  }
}
int F(char y,int id){
  return ((int)(y-'a')*a[id]+b[id])%26;
}
string change(string s,int id){
  for(int i=0;i<(int)s.size()-1;i++){
    if(s[i]==' ') continue;
    s[i]=(char)F(s[i],id)+'a';
  }
  return s;
}

int main(){
  scanf("%d",&N);
  add_ab();
  for(int i=0;i<N;i++){
    char buf[258];
    getchar();
    fgets(buf,sizeof(buf),stdin);
    string s = buf;
    for(int i=0;i<(int)a.size();i++){
      s=change(s,i);
      if(0<=(int)s.find("that") || 0<=(int)s.find("this")){
	printf("%s",s.c_str());
	break;
      }
      //      printf("ng:: %s",s.c_str());
      s=buf;
      if(i==(int)a.size()-1){
	add_ab();
      }
    }
  }
}