#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

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

int main(){
	int n;cin >> n;
	string s;
	getline(cin, s);
	while(n--){
		getline(cin, s);
		cout << func(s) << endl;
	}
	return 0;
}
/*
1
y eazqyp pnop pngtg ye obmpngt xmybp mr lygw
*/