#define _USE_MATH_DEFINES
 
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

char F(int a, int b, char c){
	return (char)((a*(c-'a')+b)%26+'a');
}

int main(){
	int n;
	cin >> n;
	cin.ignore();
	for(int i=0;i<n;i++){
		int alpha = 1;
		int beta = 0;
		string str;
		getline(cin, str);
		string tmp = str;

		while(str.find("this")==string::npos && str.find("that")==string::npos){
			str = tmp;
			beta++;
			if(beta>30){
				alpha++;
				beta=0;
			}
			for(int j=0;j<str.size();j++){
				if(str[j]>='a' && str[j]<='z'){
					str[j]=F(alpha, beta, str[j]);
				}
			}
			//cin >> str;
			//cout << alpha <<" "<<beta<<" "<<str <<endl;
		}
		cout << str <<endl;
	}
	return 0;
}