#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 999999999
#define eps 1e-9


bool solve(string s){
    if(s.find("this")!=string::npos)return true;
    if(s.find("that")!=string::npos)return true;
    return false;
}

int main(){
    int n;
    cin>>n;
    cin.ignore();
    rep(i,n){
        string s;
        getline(cin,s);
        rep(j,1000){
            rep(k,27){
                string m=s;
                rep(l,m.size()){
                    if(isalpha(m[l])){
                        m[l] = 'a'+((j*(m[l]-'a')+k)%26);
                    }
                }
//                cout<<m<<endl;
                if(solve(m)){
                    cout<<m<<endl;
                    goto end;
                }
            }
        }
    end:;
    }
}