#include <iostream>
#include <string>
using namespace std;

int alpha,beta;

char f(int c) {
    if(c == ' ') return ' ';
    return (char)(((alpha*(c-'a')+beta)%26)+'a');
}

int main() {
    int n;
    string in;
    cin>>n;
    cin.ignore();
    while(n--) {
        getline(cin, in);
        for(alpha = 2; alpha<26000; ++alpha) {
            if(26%alpha == 0) continue;

            for(beta = 0; beta <26; ++beta) {
                string ci = in;
                for(int i=0; i<ci.length(); ++i)
                    ci[i] = f(ci[i]);


                if(ci.find("this") != string::npos || ci.find("that") != string::npos) {
                    cout<<ci<<endl;
                    goto END;
                }
            }
        }
    END:;
    }
}