#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
bool isalpha(char z){
	if(z>='a'&&z<='z')return true;
	else return false;
}
int main(){
	string s,c;
	int n;
	cin>>n;
	for(int u=0;u<n;u++){
		cin.ignore();
		getline(cin,s);
		int a=0;
		bool ok=false;
		while(true){
			int b=0;
			while(true){
				c=s;
				for(int i=0;i<s.size();i++){
					if(isalpha(c[i])){
						c[i]='a'+((c[i]-'a')*a+b)%26;
					}
				}
				for(int i=0;i<s.size()-3;i++){
					if(c[i]=='t'&&c[i+1]=='h'&&c[i+2]=='i'&&c[i+3]=='s')ok=true;
					if(c[i]=='t'&&c[i+1]=='h'&&c[i+2]=='a'&&c[i+3]=='t')ok=true;
				}
				if(ok)break;
				b++;
				if(b==26)break;
			}
			if(ok)break;
			a++;
		}
		cout<<c<<endl;
	}
	return 0;
}