#include <iostream>
#include <cstdio>
#include <cctype>
using namespace std;

bool isPrimary(int num) {
    return(num % 2 != 0 && num % 13 != 0);
}
char calc(int a, int b, char chr) {
    int num = chr - 'a';
    char ret = 'a' + ((num * a + b) % 26);
    return(ret);
}

int main(void) {
    int num; string input;
    cin >> num; //cout << num << endl;
    cin.ignore(1, '\n');
    for(int r = 0; r < num; r++) {
        getline(cin, input); //cout << input << endl;
        bool found = false;
        for(int a = 0; !found; a++) {
            if(!isPrimary(a)) continue;
            for(int b = 0; b < 26 && !found; b++) {
                for(int r = 0; r < input.length(); r++) {
                    if(!isalpha(input[r])) continue;
                    input[r] = calc(a, b, input[r]);
                }
                if((input.find("this") != string::npos) || (input.find("that") != string::npos)) {
                    found = true;
                }
            }
        }
        cout << input << endl;
    }
    return(0);
}