#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
#include <sstream>
using namespace std;
 
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair
 
static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;
 
template <class T>
void initvv(vector<vector<T> > &v,int a,int b, const T  &t = T()){
    v.assign(a,vector<T>(b,t));
}
 
//v.erase(unique(v.begin(),v.end()),v.end());


int main(){
	int n;
	cin>>n;
	// cout<<n<<endl;
	string aaa;
	getline(cin,aaa);
	rep(i,n){
		string s;
		getline(cin,s);
		// cout<<s<<endl;
		string s2=s;
		rep(j,s.size()){
			if(s2[j]==' '){
				s2[j]=-1;
			}
			else{
				s2[j]=s2[j]-'a';
			}
		}
		string ans;
		bool f=false;
		rep(j,1000){
			if(j%2==0||j%13==0){
				continue;
			}
			rep(k,26){
				string tmp=s2;
				rep(l,s2.size()){
					if(tmp[l]==-1){
						tmp[l]=' ';
					}
					else{
						tmp[l]=(j*tmp[l]+k)%26;
						tmp[l]+='a';
					}
				}
				if(tmp.find("this",0)!=string::npos||tmp.find("that",0)!=string::npos){
					ans=tmp;
					f=true;
					break;
				}
				
			}
			if(f) break;
		}
		cout<<ans<<endl;
	}
}