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

string solve(string s){
	string t;
	for(int a = 1; ; ++a)
	for(int b = 0; b < 26; ++b){
		t = s;
		for(int i = 0; i < t.size(); ++i){
			if(t[i] != ' '){
				t[i] = (a * (t[i] - 'a') + b) % 26 + 'a';
			}
		}
		if(t.find("this") != string::npos || t.find("that") != string::npos){
			return t;
		}
	}
}

int main(){
	int n;
	cin >> n;
	cin.get();
	string s;
	for(int i = 0; i < n; ++i){
		getline(cin, s);
		cout << solve(s) << '\n';
	}
}