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

//const int alpha[]={3,4,5,6,7,8,9,10,11,12,14,15,16,17,18,19,20,21,22,23,24,25,27,28,29,30,31,32,33,34};

int main(){
	int n;
	int beta;
	string s, org(256,'@');
	cin >> n;
	cin.ignore();
	for(int i=0;i<n;++i){
		beta=0;
		getline(cin , s);
		while(org.find("this" ,0)==string::npos && org.find("that" , 0)==string::npos){
				for(int j=0;j<10000;++j){
						for(int k=0;k<26;++k){ 
							if((int)(s[0]-'a')==(int)((j*k+beta) % 26)){
								for(int l=0;l<s.size();++l){
									for(int m=0;m<26;++m){
										if(s[l]==' ') {org[l]=' ';  continue;}
										if((s[l]-'a')==((j*m+beta)%26)){
											org[l]=m+'a';
											break;
										}
									}
								}
							}
						}
				}
			beta++;
		}
		int index=org.find_first_of('@');
		org.erase(index);
		cout << org << endl;
		
	}
	return 0; 
}