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

string G(string s, int a, int b) {
    string ret = "";
    for (int i=0; i<(int)s.size(); ++i) {
        if (s[i] == ' ') {
            ret += ' ';
        } else {
            ret += char('a' + (a * ((s[i] - 'a') + b)) % 26);
        }
    }
    return ret;
}

int main() {
    int n;
    cin >> n;
    string s;
    while (n) {
        getline(cin, s);
        if (s.size() == 0) continue;
        n --;
        string ans = "";
        for (int a=1; a<26; ++a) {
            if (a % 2 == 0 || a % 13 == 0) continue;
            for (int b=0; b<26; ++b) {
                string t = G(s, a, b);
                if (t.find("this") != string::npos || t.find("that") != string::npos) {
                    ans = t;
                    break;
                }
            }
            if (ans != "") break;
        }
        cout << ans << endl;
    }
    return 0;
}