#include <bits/stdc++.h>
using namespace std;

using db = double;
using ll = long long;
using vi = vector <int>;
#define op operator
#define pb push_back

string trans(string s, int a, int b) {
	for(auto &c : s) if(isalpha(c)) {
		int t = c - 'a';
		t = (t * a + b) % 26;
		c = t + 'a';
	}
	return s;
}

int main() {
	ios :: sync_with_stdio(0);

	int n; cin >> n;
	string s; getline(cin, s);
	while(n --) {
		getline(cin, s);
		for(int a = 1; a < 26; a ++)
			for(int b = 0; b < 26; b ++) if(__gcd(a, 26) == 1) {
				string t = trans(s, a, b);
				bool f = 0;
				for(int i = 0; i < t.size(); i ++)
					if(t.substr(i, 4) == "this" || t.substr(i, 4) == "that")
						f = 1;
				if(f) {
					cout << t << '\n';
					goto done;
				}
			}
		done: ;
	}

	return 0;
}