#include <string>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <utility>
#include <algorithm>
#include <numeric>
#include <iostream>

using namespace std;
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

void solve(){
	string ori;
	getline(cin,ori);
	char dic[26];
	for (int b = 0; b < 26; b++){
		for (int a = 1; a < 26; a++){
			if(gcd(a,26) != 1) continue;
			string s(ori);
			for (int i = 0; i < 26; i++){
				dic[i] = (a * i + b) % 26;
			}
			for (int i = 0; i < s.length(); i++){
				if(s[i] >= 'a' && s[i] <= 'z')
					s[i] = (dic[s[i] - 'a']) + 'a';
			}
			if(s.find("that") != string::npos || s.find("this") != string::npos){
				cout << s << endl; 
				return;
			}
		}
	}
}

int main()
{
	int t; cin>>t;
	string buf; getline(cin,buf);
	while(t--){
		solve();
	}
}