#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){
        string a,b;
        int q;
        cin>>q;
        while(getline(cin,a)){
            bool flg=0;
            b=a;
            for(int x=1;x<=26;x++){
                for(int y=1;y<=26;y++){
                    if(b.find("this")!=string::npos||b.find("that")!=string::npos){
                        cout<<b<<endl,flg=1;break;
                    }
                    else{

                        for(int i=0;i<a.length();i++){
                            if(a[i]>='a'&&a[i]<='z'){
                                b[i]=((((a[i]-'a')*x)+y)%26)+'a';
                            }
                        }
                    }
                }
                if(flg==1)break;
            }
        }
    return 0;
}