#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//????????????????????????????????????
#define int long long
#define str string
const int inf = 999999999999999999;
struct P {
	int pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {
	int to, cost;
};
int gcm(int i, int j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
typedef long long ll;
typedef long double ld;
//---------------------------------------------------
//+++++++++++++++++++++++++++++++++++++++++++++++++++
//---------------------------------------------------
str s;
str solve(int i, int j) {
	str a = "";
	for (int z = 0; z < s.size(); z++) {
		if (s[z] == ' ') a += " ";
		else a += (char)((i*((int)s[z] - 'a') + j) % 26) + 'a';
	}
	for (int z = 0; z < a.size() - 4; z++) {
		str t = "";
		for (int r = 0; r < 4; r++)
			t += a[z + r];
		if (t == "that" || t == "this")
			return a;
	}
	return "shippaidesu";
}
signed main() {
	int n;
	cin >> n;
	getchar();
	for (int i = 0; i < n; i++) {
		getline(cin, s);
		for (int i = 0; i < 30; i++) {
			if (gcm(26, i) > 1&&i!=0)
				continue;
			for (int j = 0; j < 30; j++) {
				if (solve(i, j) != "shippaidesu") {
					cout << solve(i, j) << endl;
					goto stop;
				}
			}
		}
	stop:;
	}
	getchar(); getchar();
}