#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n;
	cin>>n;
	string tmp;
	getline(cin,tmp);
	while(n--){
		getline(cin,tmp);		
		rep(a,10000){
			bool h=false;
			rep(b,26){
				string s=tmp;
					rep(k,s.size())if(isalpha(s[k]))s[k]=(a*(s[k]-'a')+b)%26+'a';
				if(s.find("this")!=string::npos||s.find("that")!=string::npos){
					cout<<s<<endl;
					h=true;break;
				}
				if(h)break;
			}
			if(h)break;
		}
	}
}