#include <iostream>
#include <string>

using namespace std;

int a, b;
const int alpha[] = {1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25};

inline char affine(char ch)
{
    return (alpha[a] * ch + b) % 26 + 'a';
}

void solve()
{
    string str;

    getline(cin, str);
    str += ' ';
    string::size_type pos1, pos2;
    bool flag = false;

    for (pos2 = str.find(' '), pos1 = 0; pos2 != string::npos;
         pos1 = pos2 + 1, pos2 = str.find(' ', pos1)) {
        if (str.substr(pos1, pos2 - pos1).size() == 4) {
            string tmp = str.substr(pos1, pos2 - pos1);

            for (int ai = 0; ai < 12; ai++) {
                for (int bi = 1; bi < 26; bi++) {
                    string cmp = "";
                    a = ai;
                    b = bi;

                    for (int i = 0; i < tmp.size(); i++) 
                        cmp.push_back(affine(tmp[i]));
                    if (cmp == "this" || cmp == "that") {
                        flag = true;
                        break;
                    }
                    if (flag)
                        break;
                }
                if (flag)
                    break;
            }
        }
        if (flag)
            break;
    }

    for (int i = 0; i < str.size() - 1; i++) {
        if (isalpha(str[i]))
            cout << affine(str[i]);
        else
            cout << str[i];
    }
    cout << endl;
}


int main()
{
    int n;
    
    cin >> n;
    cin.ignore();
    while (n--) {
        solve();
    }

    return 0;
}