#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
#include <cstdio>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define pb(a) push_back(a)
int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  int num;
  cin>>num;
  cin.ignore();
  rep(i,num){
    string s,ss;
    getline(cin,s);
    bool flag = true;
    ss = s;
    rep(i,26){
      rep(j,26){
	if(ss.find("that") == string::npos & ss.find("this") == string::npos){
	  rep(k,s.size()){
	    ss=((((s[i]-'a')*i)+j)%26)+'a';
	    
	  }
	    
	}else{
	  cout<<ss<<endl;
	  flag = false;
	  break;
	}
      }
      if(!flag){
	break;
      }
    }
  }
}