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

int main(void) {
	int n;
	cin >> n;
	string input;
	getline(cin, input);
	while(n--) {
		getline(cin, input);
		bool flag = true;
		for(int a = 1; a <= 26 && flag; a++) {
			if(26 % a == 0)
				continue;
			for(int b = 0; b < 26; b++) {
				string str = input;
				int l = str.size();
				for(int i = 0; i < l; i++) {
					if(str[i] >= 'a' && str[i] <= 'z')
						str[i] = (a * (str[i] - 'a') + b) % 26 + 'a';
				}
				if(str.find("this") != string::npos || str.find("that") != string::npos) {
					flag = false;
					cout << str << '\n';
				}
			}
		}
	}
}