#include <bits/stdc++.h>

using namespace std; 
 
map<char, int> c2i;
map<int, char> i2c;
string str;
 
void init()
{
    for (char ch = 'a'; ch <= 'z'; ch++) {
	c2i[ch] = ch - 'a';
	i2c[ch - 'a'] = ch;
    }
}
 
bool serch(string s)
{
    string str;
    stringstream ss(s);
    while (ss >> str) {
        if (str == "this" || str == "that") {
            return 1;
        }
    }
    return 0;
}
 
char F(char ch, int a, int b)
{
    int num = (a * c2i[ch] + b) % 26; 
    return i2c[num];
}
 
int main()
{
    int n;
    init(); 
    cin >> n;
    cin.ignore();
    while (n--) {
	getline(cin, str);
 
	for (int i = 0; i < 26; i++) {
	    for (int j = 0; j < 26; j++) {
		string next;
		for (int k = 0; k < (int)str.size(); k++) {
		    if (islower(str[k])) {
                        next += F(str[k], i, j);
		    } else {
                        next += str[k];
                    }
                }
		if (serch(next)) {
		    cout << next << endl;
                    goto END;
		}
	    }
	}
        END:;
    }
    return 0;
}