#include <iostream>
#include <algorithm>
#include <string>
using namespace std;


bool IsCoprime(int a, int b)
{
	while (a > 0 && b > 0)
	{
		if (a < b) swap(a, b);
		a %= b;
	}
	if (a == 1 || b == 1) return true;
	return false;
}


char get(int a, int b, char c)
{
	for (int i = 0; i < 26; i++)
	{
		if ((a * i + b) % 26 == c - 'a') return char(i + 'a');
	}
}


int main()
{
	int n;
	string cip;
	string dec;

	cin >> n;
	cin.get();

	while (n--)
	{
		getline(cin, cip);
		dec = cip;

		for (int a = 0; a < 26; a++)
		{
			if (!IsCoprime(a, 26)) continue;
			for (int b = 0; b < 26; b++)
			{
				for (int i = 0; i < cip.size(); i++)
				{
					dec[i] = get(a, b, cip[i]);
				}
				if (dec.find("that") != -1 || dec.find("this") != -1)
				{
					cout << dec << endl;
				}
			}
		}
	}

	return 0;
}