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

string cipher(const string& input, int alpha, int beta){
    size_t len = input.size();
    string output = input;

    for (int i = 0; i < len; i++) {
        if (input[i] == ' ') {
            output[i] = input[i];
        } else {
            output[i] = (alpha * (input[i] - 'a') + beta) % 26 + 'a';
        }
    }

    return output;
}

int main(int argc, char const* argv[])
{
    int n;
    cin >> n;
    cin.ignore();

    for (int i = 0; i < n; i++) {
        string input;
        getline(cin, input);

        for (int alpha = 0; alpha < 26; alpha++) {
            for (int beta = 0; beta < 26; beta++) {
                string output = cipher(input, alpha, beta);
                if (output.find("this") != string::npos || output.find("that") != string::npos) {
                    cout << output << endl;
                }
            }
        }
    }

    return 0;
}