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

int main() {
	int n;
	cin >> n;
	for (int i = 0;i < n;i++) {
		string s;
		getchar();
		getline(cin, s);
		int a = s.size();

		for (int j = 0;j < 26;j++) {
			for (int k = 0;k < 26;k++) {
				string sa = s;
				for (int l = 0;l < a;l++) {
					if (sa[l] >= 'a'&&sa[l] <= 'z') {
						int b = sa[l] - 97;
						b =( b*j + k)%26;
						b += 97;
						sa[l] = b;
					}
				}
				size_t za = sa.find("that");
				size_t zb = sa.find("this");
				if (za != string::npos || zb != string::npos) {
					s = sa;
					goto finloop;
				}
			}
		}
	finloop:
		cout << s << endl;
	}
	return 0;
}