#include <iostream>
#include <sstream>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <iomanip>
using namespace std;
int main(){
	int n;
	cin >> n;
	cin.ignore();
	while(n-->0){
		string s;
		getline(cin,s);
		int ans;
		for(int i=1;i<26;i++){
		for(int k=0;k<26;k++){
			string w = s;
			for(int j=0;j<s.size();j++) if(w[j]!=' ') w[j] = ((w[j]-'a')*i+k)%26+'a';
			istringstream is(w);
			string t;
			bool a = false;
			while(is >> t){ if(t=="that" or t=="this"){ a = true; break; } }
			if(a) s = w;
			if(a) break;
		}}
		cout << s << endl;
	}
}