#include <iostream>
#include <vector>

using namespace std;
const vector<int> v{1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25};

int main() {
    string n;
    getline(cin, n);

    for (int count = 0; count < stoi(n); count++) {
        string s;
        getline(cin, s);

        bool finished = false;
        for (auto alpha:v) {
            vector<int> conv(26);
            for (int beta = 0; !finished && beta < 26; beta++) {
                for (int c = 0; c < 26; c++) {
                    int x = alpha * c + beta;
                    conv[x % 26] = c;
                }

                string after = s;
                for (int i = 0; i < s.size(); i++) {
                    if (after[i] == ' ')continue;
                    after[i] = conv[after[i] - 'a'] + 'a';
                }

                bool found = false;
                for (int i = 0; i < after.size() - 3; i++) {
                    string now = after.substr(i, 4);
                    if (now == "that" || now == "this")found = true;
                }
                if (found) {
                    cout << after << endl;
                    finished = true;
                }
            }
        }
    }
    return 0;
}
