#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
using namespace std;

int main() {

    string cip;
    getline(cin, cip);

    while(getline(cin, cip)) {
        bool hit = false;
        for(int a = 1; a < 26; a++) {
            if ( a % 2 == 0 || a == 13 )    continue;
            for(int b = 0; b < 26; b++) {
                string test = cip;
                for(int c = 0; c < cip.length(); c++) {
                    if ( cip[c] != ' ' ) test[c] = ((cip[c] - 'a') * a + b) % 26 + 'a';
                }
                if ( test.find("this") != string::npos || test.find("that") != string::npos ) {
                    hit = true;
                    cip = test;
                    break;
                }
            }
            if(hit) break;
        }
        cout << cip << endl;
    }

    return 0;
}