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