#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <functional>
#include <sstream>
#include <complex>
#include <climits>
using namespace std;

#define REP(i,a,n) for(int i=(a);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define EPS 1e-8

string chipher(string s, int a, int b){
	rep(i,s.size())if( 'a'<=s[i] && s[i]<='z' ){
		s[i] = ((a*(s[i]-'a') + b)%26)+'a';
	}
	return s;
}
int gcd(int x, int y){
	return y ? gcd(y,x%y) : x;
}
int main(){
	int t;
	scanf("%d ",&t);
	while(t--){
		string in,ans; getline(cin,in);
		bool f = false;
		//cout << in << endl;
		for(int a=1; a<26; a++)if( gcd(a,26)==1 ){
			for(int b=1; b<=26; b++){
				string tmp = chipher(in,a,b);
				//printf("(%d,%d)::%s\n",a,b,tmp.c_str());
				if( tmp.find("that")!=string::npos || tmp.find("this")!=string::npos ){
					f = true; ans = tmp; break;
				}
			}
			if( f ) break;
		}
		cout << ans << endl;
	}
	return 0;
}