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

string THIS = "this", THAT = "that";
int gcd(int a, int b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}
int main() {
	int a;
	string b;
	cin >> a;
	getline(cin, b);
	for (int c = 0; c < a; c++) {
		getline(cin, b);
		for (int d = 1; d < 26; d++) {
		l:;
			for (int e = 0; e < 26; e++) {
				if (gcd(d, 26) != 1)continue;
				string s;
				for (int f = 0; f < b.length(); f++) {
					if (b[f] == ' ')s += ' ';
					else {
						for (int g = b[f] - 'a';g<26*26+'a'; g += 26) {
							if ((g - e) % d == 0 && (g - e) / d >= 0 && (g - e) / d < 26) { s += ((g - e) / d + 'a'); goto r; }
						}
						goto l;
					r:;
					}
				}
				for (int i = 0; i < s.length() - 4; i++) {
					bool x = true, y = true;
					for (int p = 0; p < 4; p++) {
						if (s[i + p] != THIS[p])x = false;
						if (s[i + p] != THAT[p])y = false;
					}
					if (x | y) { cout << s << endl; break; }
				}
			}
		}
	}
}