#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)

string c;

string solve(){
    int n = c.size();
    string p(n, ' ');
    rep(a,26){
        if(__gcd(a,26) != 1) continue;
        rep(b,26){
            char dic[256];
            rep(x, 26){
                int y = (x*a + b) % 26;
                dic[y + 'a'] = x + 'a';
            }
            dic[(int)' '] = ' ';
            rep(i,n) p[i] = dic[(int)c[i]];
            if(p.find("this") != string::npos || p.find("that") != string::npos) return p;
        }
    }
    assert(false);
}

int main(){
    int n;
    cin >> n;
    cin.ignore();
    rep(i,n){
        getline(cin, c);
        cout << solve() << endl;
    }
}