#include <string>
#include <iostream>
#include <cctype>
#include <algorithm>
#include <cstdlib>
using namespace std;
char f(int a, int b, int c) { return (a*c + b) % 26 + 'a'; }
int main()
{
	string p; getline(cin, p);
	int N = atoi(p.c_str());
	while (N--) {
		string s; getline(cin, s);
		for (int a=0; a<26; ++a) {
			if (__gcd(a, 26) != 1) continue;
			for (int b=0; b<26; ++b) {
				string t = s;
				bool ok = true;
				for (int i=0; i<s.size(); ++i) {
					if (isalpha(s[i])) {
						t[i] = f(a, b, s[i]-'a');
						if (!isalpha(t[i])) { ok = false; break; }
					}
					else t[i] = s[i];
				}
				if (ok && t.find("that") != string::npos || t.find("this") != string::npos) {
					cout << t << endl;
					goto BREAK;
				}
			}
		}
BREAK:;
	}
	return 0;
}