#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;
    scanf("%d", &num); //cout << num << endl;
    for(int r = 0; r < num; r++) {
        getline(cin, input); //cout << input << endl;
        getline(cin, input);
        bool found = false;
        
        for(int a = 0; a <= 26 && !found; a++) {
            for(int b = 0; b <= 26 && !found; b++) {
                if(isPrimary(a)) { //aと26が互いに素であるならば
                    for(int r = 0; r < input.length(); r++) {
                        if(!isalpha(input[r])) continue;
                        //cout << "choice:" << r << endl;
                        input[r] = calc(a, b, input[r]);
                    }
                    if((input.find("this") != string::npos) || (input.find("that") != string::npos)) {
                        found = true; //cout << input << endl;
                    }
                }
                    //cout << "新しい文字列：" << input << endl;
            }
        }
        cout << input << endl;
    }
    return(0);
}