#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,a) loop(i,0,a)
string m,p;
int main(){
    int n;cin>>n;
    cin.ignore();
    while(n--){
        getline(cin,m);
        p.resize(m.size());
        for(int a=1;;a++){
            if(__gcd(a,26)!=1) continue;
            rep(b,26){
                char dic[256];
                rep(from,26){
                    int to=from*a+b;
                    to%=26;
                    dic[to+'a']=from+'a';
                }
                dic[' ']=' ';
                rep(i,m.size()){
                    p[i]=dic[(int)m[i]];
                }
                if(p.find("this")==(size_t)-1&&
                   p.find("that")==(size_t)-1) continue;
                cout<<p<<endl;
                goto end;
            }
        }
    end:;
    }
}