#include<iostream>
#include<fstream>
#include<sstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdlib>
using namespace std;

#define ull unsigned long long
#define ll long long
#define PI 3.141592654

int module(int num){
	if(num > 0){
		return num%26;
	}	
	while(abs(num)>26)num +=26;
	return 26+num;
}

vector<string> that(string line){
	vector<string> word;
	int b = 0;
	string tmp = "";
	while(line[b] != 0){
		if(line[b] == ' '){
			word.push_back(tmp);
			tmp = "";
		}else{
			tmp += line[b];
		}
		b++;
	}

	if(tmp.size() > 0)word.push_back(tmp);
	vector<string> res;

	for(int x=0;x<word.size();++x){
		if(word[x].size()==4)res.push_back(word[x]);
	}
	return res;
}

int inv(int a){
	for(int x=1;x<26;++x){
		if((a*x)%26 == 1)return x;
	}
	return -1;
}

string solve(string org,int a,int b){
	string ret = "";
	for(int x=0;x<org.size();++x){
		if(org[x] == ' '){
			ret += " ";
		}else{
	//		cout<<a<<"#"<<inv(a)<<endl;
			ret += 'a' + (inv(a)*module(org[x]-b-'a'))%26;
		}
	}
	return ret;
}

int main(){
	int n;
	string line;
	while(getline(cin,line)){
		sscanf(line.c_str(),"%d",&n);
		for(int i=0;i<n;++i){
		 	getline(cin,line);
			vector<string> cand = that(line);
			bool flag = true;
			for(int c=0;c<cand.size() && flag;++c){
				for(int a=1;a<26 && flag;a+=2){
					int b = module(cand[c][0]-'a'-a*('t'-'a'));	
					string rta = solve(line,a,b);
	//				cout<<a<<":"<<b<<endl;
	//				cout<<rta<<endl;	
					if(rta.find("that")!=string::npos || rta.find("this")!=string::npos){
						cout<<rta<<endl;
						flag = false;
					}
				}
			}
		}
	}
	return 0;
}