#include <iostream>
#include <string>

using namespace std;

string affine(string s, int alpha, int beta)
{
	string aff_str;	aff_str.clear();
	for (string::iterator it = s.begin(); it != s.end(); it++) {
		if ( *it == ' ' ) aff_str.push_back(' ');
		else {
			char c = *it - 'a';
			c = (alpha * c + beta) % 26;
			aff_str.push_back(c + 'a');
		}
	}
	return aff_str;
}

int gcd(int x, int y)
{
	if (x==0) return y;
	if (y==0) return x;
	if (y>x)  return gcd(x, y%x);
	return gcd(y, x%y);
}

bool isRelPrime(int x, int y)
{
	return gcd(x, y) == 1;
}

int main()
{
	string buf;
	int n;
	cin >> n;
	
	//char dummy;
	//cin >> dummy; // discard '\n' after the input of n
	
	cin.ignore();
	
	for (int i=0; i<n; i++) {
		buf.clear();
		getline(cin, buf);
		//cout << buf.size() << " " << buf << endl;
		bool success = false;
		for (int alpha = 1; alpha < 26; alpha++) {
			if ( !isRelPrime(alpha, 26) ) continue;
			for (int beta = 0; beta < 26; beta++) {
				string decoded = affine(buf, alpha, beta);
				//cout << decoded << endl;
				if ( (decoded.find("that") != string::npos) || (decoded.find("this") != string::npos) ) {
					cout << decoded << endl; success = true; break;
				}
			}
			if (success) break;
		}
	}
	
	return 0;
}