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

int main() {
	string s;
	int q;
	cin >> q;
	for(int i = 0; i < q + 1; ++i){
		getline(cin, s);
		string t = s;
		for(int x = 1; x <= 26; ++x){
			for(int y = 1; y <= 26; ++y){
				if(t.find("that") != string::npos || t.find("this") != string::npos){
					cout << t << endl;
					goto end;
				}
				else{
					for(int j = 0; j < s.size(); ++j){
						if('a' <= s[j] && s[j] <= 'z')
							t[j] = ((((s[j] - 'a') * x + y)) % 26) + 'a';
					}
				}
			}
		}
		end:;
	}
	return 0;
}