#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<map>
#include<queue>
#include<set>

using namespace std;
typedef pair<int,int> PII;
typedef long long ll;

int main(){
	int n;
	string line;
	cin>>n;
	getline(cin,line,'\n');
	for(;n>0;n--){
		getline(cin,line,'\n');
		int alpha[12] = {1,3,5,7,9,11,15,17,19,21,23,25};
		for(int b,i=0;i<12;i++){
			for(b = 0;b<26;b++){
				char chiper[26];
				for(int j=0;j<26;j++)
					chiper[j] = (alpha[i]*j+b)%26 + 97;
				string decode = line;
				for(int j=0;j<line.size();j++){
					if(line[j]>=97&&line[j]<=122)
						decode[j] = chiper[line[j]-97];
					else
						decode[j] = line[j];
				}
				if(decode.find("this") != -1 || decode.find("that") != -1){
					cout<<decode<<endl;
					break;
				}
			}
			if(b!=26)break;
		}
	}
  return 0;
}