#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
	int n,ar[] = {1,3,5,7,9,11,15,17,19,21,23,25};
	cin >>n;
	for(int i=0; i<n; i++){
		char word[300] = {0};
		int f = 0;
		for(int j=0;;j++){
			if(scanf("%c",&word[j]) == EOF){word[j] = 0;break;}
			if(word[j] == '\n'){break;}
		}
		for(int i=0; i<12; i++){
			for(int j=0; j<26; j++){
				for(int k=0; k<(int)strlen(word); k++){
					if(word[k]>='a' && word[k]<='z'){word[k] = (ar[i]*(word[k]-'a')+j)%26+'a';}
				}
				if(strstr(word," this ") != NULL){cout<<word;f = 1;break;}
				else if(strstr(word,"this ") != NULL){cout<<word;f = 1;break;}
				else if(strstr(word," this\n") != NULL){cout<<word;f = 1;break;}
				else if(strstr(word,"this\n") != NULL){cout<<word;f = 1;break;}
				else if(strstr(word," that ") != NULL){cout<<word;f = 1;break;}
				else if(strstr(word,"that ") != NULL){cout<<word;f = 1;break;}
				else if(strstr(word," that\n") != NULL){cout<<word;f = 1;break;}
				else if(strstr(word,"that\n") != NULL){cout<<word;f = 1;break;}
			}
			if(f == 1){break;}
		}
		if(f == 1){break;}
	}
	return 0;
}