#include<cstdio>
#include<iostream>
#include<string>

using namespace std;

int main(void){

	string sthat[26][26],sthis[26][26];
	for(int a=0;a<25;a++){
		for(int b=0;b<25;b++){
			sthat[a][b]=(char)((a*('t'-'a')+b)%26+'a');
			sthat[a][b]+=(char)((a*('h'-'a')+b)%26+'a');
			sthat[a][b]+=(char)((a*('a'-'a')+b)%26+'a');
			sthat[a][b]+=(char)((a*('t'-'a')+b)%26+'a');
			sthis[a][b]=(char)((a*('t'-'a')+b)%26+'a');
			sthis[a][b]+=(char)((a*('h'-'a')+b)%26+'a');
			sthis[a][b]+=(char)((a*('i'-'a')+b)%26+'a');
			sthis[a][b]+=(char)((a*('s'-'a')+b)%26+'a');
		}
	}

	int n;
	string in,inp;
	int mm;

	cin>>n;
	getchar();
	for(int i=0;i<n;i++){
		inp=("");
		while(1){
			in=getchar();
			if(in=="\n") break;
			else inp+=in;
		}
		for(int a=0;a<25;a++){
			for(int b=0;b<25;b++){
				if(inp.find(sthat[a][b])!=-1||inp.find(sthis[a][b])!=-1){
					for(int j=0;j<inp.length();j++){
						if(inp[j]!=' '){
							for(int k=26;;k+=26){
								if(((inp[j]-'a')+k-b)%a==0){
									mm=((inp[j]-'a')+k-b)/a;
									while(mm>=26) mm-=26;
									inp[j]=(char)(mm+'a');
									break;
								}
							}
						}
					}
				}
			}
		}
		cout<<inp<<endl;
	}

	return 0;
}