#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
	int n , alpha , beta;
	string s,org;
	cin >> n;
	cin.ignore();
	for(int i=0;i<n;++i){
		getline(cin , s);
		org=s;
		while(1){
				for(alpha=3;alpha<26;++alpha){
						if(alpha){
							if(26%alpha==0) continue;
						}
					for(beta=0;beta<=26;++beta){
						for(int k=0;k<26;++k){
							if((s[0]-'a')==(alpha*k+beta)%26){
								for(int l=0;l<s.length();++l){
									for(int m=0;m<26;++m){
										if(isalpha(s[l])){
											int t=s[l]-'a';
											org[l]=(alpha*t+beta)%26+'a';
											}
										}
									}
								if(org.find("this" ,0)!=string::npos || org.find("that" , 0)!=string::npos) goto result;
							}
						}
					}
				}
		}
		result:;
		cout << org << endl;
	}
	return 0;
}