#include <iostream>
#include <string>
using namespace std;

string decode(string s) {
	for (int a=1; a<26; ++a) {
		for (int b=0; b<26; ++b) {
			string t = "";
			for (int i=0; i<(int)s.size(); ++i) {
				if (s[i] == ' ') {
					t += ' ';
				} else {
					t += char('a' + (a * (s[i] - 'a' + b)) % 26);
				}
			}
			if (t.find("this") != string::npos || t.find("that") != string::npos) {
				return t;
			}
		}
	}
}

int main() {
	int n;
	cin >> n;
	cin.ignore();
	string s;
	while (n--) {
		getline(cin, s);
		cout << decode(s) << endl;
	}
	return 0;
}