#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 - 'a') + b) % 26 + 'a';
}

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

	string str, res;
	while(n--) {
		getline(cin, str);

		a = b = 0;
		rep(a, 26) {
			rep(b, 26) {
				res = "";
				c = 0;
				rep(c, str.size()) {
					if (str[c] == ' ') {
						res += " ";
						continue;
					}

					res += ch(a, b, str[c]);
				}
				if (res.find("this") != string::npos || res.find("that") != string::npos) {
					cout << res << endl;
					a = 26;
					b = 26;
				}
			}
		}
	}
	return 0;
}