#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

map<char, char> computeMap(int a, int b) {
	map<char, char> res;
	for (int x = 0; x < 26; x++) {
		int y = (a * x + b) % 26;
		res[y + 'a'] = x + 'a';
	}

	return res;
}

string decode(string str, map<char, char> m) {
	for (auto &c : str) {
		c = isalpha(c) ? m[c] : c;
	}
	return str;
}

string solve(string str) {
	for (int a = 0; a < 26; a++) {
		for (int b = 0; b < 26; b++) {
			if (__gcd(a, 26) != 1) continue;
			map<char, char> m = computeMap(a, b);
			string decoded = decode(str, m);
			if (decoded.find("that") != string::npos || 
				decoded.find("this") != string::npos) {
				return decoded;
			}
		}
	}
	return "hoge";
}

int main(void) {
	int N;
	cin >> N;
	cin.get();

	for (int i = 0; i < N; i++) {
		string str;
		getline(cin, str);
		cout << solve(str) << endl;
	}

	return 0;
}