#include <iostream>
#include <map>
#include <stdio.h>
using namespace std;

int gcd2(int a,int b){
	while(b!=0){
		int w=a%b;
		a=b;
		b=w;
	}
	return a;
}

int main(void){
  int n;cin>>n;
  cin.ignore();
  while(n--){
    string s;
    getline(cin,s);
    bool f=true;
    for(int a=0;f;++a){
      if(gcd2(a,26)!=1) continue;
      for(int b=0;b<26&&f;++b){
        map<char,char> T;
        for(char c='a';c<='z';++c){
          T[((c-'a')*a+b)%26+'a']=c;
        }
        string s1;
        for(int i=0;i<s.size();++i)s1+=('a'<=s[i]&&s[i]<='z')?T[s[i]]:s[i];
        //cerr<<s1<<endl;
        if(s1.find("this") != -1|| s1.find("that") != -1){cout<<s1<<endl;f=false;}
      }
    }
  }
  return 0;
}