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

string AffineCipher(string s, int a, int b){
	for (int i = 0; i < s.size(); ++i){
		if (s[i] >= 'a' && s[i] <= 'z')
			s[i] = (a*(s[i] - 'a') + b) % 26 + 'a';
	}
	return s;
}

string DeAffine(string s, int a, int b){
	int t;
	for (int i = 0; i < s.size(); ++i){
		if (s[i] >= 'a' && s[i] <= 'z'){
			t = (((s[i] - 'a') - b) * a);
			while(t<0)
				t+=26;
			s[i] = t % 26 + 'a';
		}
	}

	return s;

}

int main(){
	int n, b;
	int a[12] = { 1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25 };
	string s,t;
	string key1, key2;
	cin >> n;cin.ignore();

	for (int j = 0; j < n; ++j){
		
		getline(cin,s);
		
		for (int i = 0; i < 12;++i){

			for (b = 1; b <= 26; ++b){
				
				t = DeAffine(s,a[11-i],b);
				
				if (t.find("this") != -1 || t.find("that") != -1){
					cout << t << endl;
				}
			}
		}
	}
}