#include<bits/stdc++.h>
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
void solve() {
	string s; getline(cin, s);
	for1(a, 25) {
		if (a % 2 == 0 || a % 13 == 0)continue;
		for0(b, 26) {
			string s1;
			for (char ch : s)if (ch != ' ')s1 += 'a' + ((ch - 'a') * a + b) % 26; else s1 += ' ';
			if (s1.substr(0, 5) == "this " || s1.substr(0, 5) == "that " || s1.find(" this ") < s.size() || s1.find(" that ") < s.size() || s1.substr(s1.size() - 5, 5) == " this" || s1.substr(s1.size() - 5, 5) == " that") {
				cout << s1 << endl;
				return;
			}
		}
	}
}
signed main() {
	string n; getline(cin, n);
	for0(i, stoi(n))solve();
}
