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

void solve(string& s){
	for(int i = 1; i < 26; i+=2){
		if(i == 13)continue;
		for(int j = 0; j < 26; ++j){
			string ss = s;
			for(int k = 0; k < (int)s.size(); ++k){
				if('a' <= ss[k] && ss[k] <= 'z'){
					ss[k] = (i * (ss[k] - 'a') + j) % 26 + 'a';
				}
			}
			if(ss.find("this") != string::npos || ss.find("that") != string::npos){
				cout << ss << endl;
				return;
			}
		}
	}
}

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