#include <iostream>
#include <string>
#include <vector>
#include <cstdio>

using namespace std;

int main() {
	string abc = "abcdefghijklmnopqrstuvwxyz";
	string n;
	int nn;
	char c;
	cin >> nn >> c;
	for (int p = 0; p < nn; p++) {
		getline(cin, n);
		if (p == 0) {
			n = c+n;
		}
		vector<int> data(n.size(), -1);
		for (int i = 0; i < n.size(); i++) {
			for (int j = 0; j < abc.size(); j++) {
				if (n[i] == abc[j]) {
					data[i] =j;
					break;
				}
			}
		}
		string b;
		for (int i = 3; ; i++) {
			if (i % 2 != 0 && 1 % 13 != 0) {
				bool hantei = false;
				for (int j = 0; j < 26; j++) {
					string c = "";
					for (int k = 0; k < n.size(); k++) {
						if (data[k] == -1) {
							c += ' ';
						} else {
							c += abc[(i*data[k]+j)%26];
						}
					}
					if (c.find("this") != string::npos || c.find("that") != string::npos) {
						b = c;
						hantei = true;
						break;
					}
				}
				if (hantei) {
					break;
				}
			}
		}
		cout << b << endl;
	}
	return 0;
}