#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define iss istringstream
#define sst stringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

int n;
ll x,y;
string s;

ll extgcd(ll a,ll b,ll& x, ll& y){
	ll d=a;
	if(b)d=extgcd(b,a%b,y,x),y-=(a/b)*x;
	else x=1,y=0;
	return d;
}

ll mod_inverse(ll a,ll m){
	ll x,y;
	extgcd(a,m,x,y);
	return ((ll)m+x%m)%m;
}

int main(){
	cin>>n;
	getline(cin,s);
	while(n--){
		getline(cin,s);
		rep(i,26)rep(j,26)if(extgcd(i,26,x,y)==1){
			string t=s;
			rep(k,t.sz)if(t[k]!=' '){
				int x=(t[k]-'a'-j+26)%26;
				t[k]='a'+(x*mod_inverse(i,26))%26;
			}
			if(t.find("this")!=-1||t.find("that")!=-1){
				cout<<t<<endl;
				goto nx;
			}
		}
		nx:;
	}
}