#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);
}
bool sfind(string s, string l) {//?????????1??????????????????2????????????
	for (int i = 0; i <= s.size() - l.size(); i++) {
		str t = "";
		for (int j = 0; j < l.size(); j++)
			t += s[i + j];
		if (t == l)
			return 1;
	}
	return 0;
}
typedef long long ll;
typedef long double ld;
//---------------------------------------------------
//+++++++++++++++++++++++++++++++++++++++++++++++++++
//---------------------------------------------------
signed main() {
	int n;
	cin >> n;
	getchar();
	for (int r = 0; r < n; r++) {
		string s;
		getline(cin, s);
		for (int i = 0; i < 26; i++) {
			for (int j = 0; j < 26; j++) {
				string a = "";
				for (int z = 0; z < s.size(); z++) {
					if (s[z] == ' ')
						a += " ";
					else
						a += (char)((((s[z] - 'a')*i + j) % 26) + 'a');
				}
				if (sfind(a, "that") || sfind(a, "this")) {
					cout << a << endl;
					goto stop;
				}
			}
		}
	stop:;
	}
	getchar(); getchar();
}