#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<numeric>
using namespace std;
const int dx[]={1,0,-1,0};
const int dy[]={0,1,0,-1};
#define INF 1e+8
#define EPS 1e-7
#define PB push_back
#define fi first
#define se second
#define ll long long
#define MOD 26
#define reps(i,j,k) for(int i = (j); i < (k); i++)
#define rep(i,j) reps(i,0,j)
typedef pair<int,int> Pii;
typedef vector<int> vi;
int main(){
	int n;
	scanf("%d",&n);
	while(n--){
		getchar();
		string str;
		getline(cin,str);
		string en = "abcdefghijklmnopqrstuvwxyz";
		string ans = "";
		rep(i,10000){
			if(i%2 == 0 || i%13 == 0)continue;
			rep(j,26){
				string sub;
				rep(k,str.size()){
					if(str[k] == ' ')sub += " ";
					else sub += en[((i*(str[k]-'a')+j) % MOD)];
				}
				rep(k,sub.size()-4){
					if(sub[k] == 't'&&sub[k+1] == 'h'&&sub[k+2] == 'i'&&sub[k+3] == 's'){
						ans = sub;
						goto end;
					}
					if(sub[k] == 't'&&sub[k+1] == 'h'&&sub[k+2] == 'a'&&sub[k+3] == 't'){
						ans = sub;
						goto end;
					}
				}
			}
		}
		end:;
		cout << ans << endl;
	}
	return 0;
}