#include <iostream>
#include <string>
using namespace std;

#define rep(i,j) for(; i < j; i++)

char ch(int a, int b, int c) {
	return (a * c + b) % 26;
}

int main() {
	int n, a, b, c;
	cin >> n;
	cin.ignore();

	string str, res;
	for (; n > 0; n--) {
		getline(cin, str);

		a = b = 1;
		rep(a, 100) {
			if (a == 2 || a == 13) continue;
			rep(b, 100) {
				res = str;
				c = 0;
				rep(c, str.size()) {
					if (res[c] == ' ') continue;

					res[c] = ch(a, b, res[c] - 'a') + 'a';
				}
				if (res.find("this") != -1 || res.find("that") != -1) {
					cout << res << endl;
					a = 114514;
					b = 114514;
				}
			}
		}
	}
	return 0;
}