#include <iostream>
#include <string>
using namespace std;
string G(string s) {
	for (int a=1; a<26; ++a) {
		for (int b=0; b<26; ++b) {
			string t = s;
			for (int i=0; i<t.size(); ++i) {
				if (islower(t[i])) {
					t[i] = 'a' + (a * (s[i] - 'a' + b)) % 26;
				}
			}
			if (t.find("this") != -1 || t.find("that") != -1) {
				return t;
			}
		}
	}
}
int main() {
	int n;
	cin >> n;
	cin.ignore();
	string s;
	while (n--, getline(cin, s)) {
		cout << G(s) << endl;
	}
	return 0;
}