#include <iostream>

using namespace std;

int main(){
	int n;
	cin >> n;
	string s;
	getline(cin, s);
	while(n--){
		getline(cin, s);
		bool accept = false;
		for(int a = 1; !accept; ++a){
			if(a % 2 == 0 || a % 13 == 0){ continue; }
			for(int b = 0; !accept && b < 26; ++b){
				char map[26];
				for(int i = 0; i < 26; ++i){
					map[(i * a + b) % 26] = i + 'a';
				}
				string t = s;
				for(int i = 0; i < t.size(); ++i){
					if(islower(t[i])){ t[i] = map[t[i] - 'a']; }
				}
				bool found_this = (t.find("this") != string::npos);
				bool found_that = (t.find("that") != string::npos);
				if(found_this || found_that){
					s = t;
					accept = true;
				}
			}
		}
		cout << s << endl;
	}
	return 0;
}