#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
using namespace std;
#define M_PI 3.141592
#define toRad 2.0*M_PI/360.0
#define inin(x) int x;cin>>x;
#define all(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" "<<x<<endl;
int euclid(int a, int b)
{
	if (a < b)swap(a, b);
	if (b == 0)return a;
	else return euclid(b, a%b);
}
char hoge(int a)
{
	return 'a' + a;
}
bool check(string a)
{
	if (a.find("that", 0) != string::npos || a.find("this", 0) != string::npos)
	{
		return true;
	}
	return false;
}
int main()
{
	int n;
	cin >> n; cin.ignore();
	while (n--)
	{
		string str;
		bool ok = true;
		getline(cin, str);
		for (int a = 0; ok; a++)
		{
			if (euclid(a, 26) != 1)continue;
			for (int b = 0; ok&& b < 26; b++)
			{
				string ans = "";
				for (int i = 0; i < str.size(); i++)
				{
					if (str[i] == ' ') {
						ans += " "; continue;
					}
					for (int y = 0; y < 26; y++)
					{
						int num = (a*y + b) % 26;
						if (hoge(num) == str[i])
						{
							ans += hoge(y);
							break;
						}
					}
				}
				if (check(ans))
				{
					cout << ans << endl;
					ok = false;
				}
			}
		}
	}
}