#include<iostream>
#include<string>
std::string decipher(std::string src, int alpha, int beta)
{
	for (auto&i : src)
	{
		if ('a' <= i && i <= 'z')
		{
			i = ((i - 'a') * alpha + beta) % 26 + 'a';
		}
	}
	return src;
}
int main()
{
	int n;
	std::cin >> n;
	std::cin.ignore();
	for (int i = 0; i < n; i++)
	{
		std::string origin;
		std::getline(std::cin, origin);
		for (int alpha = 0; alpha < 100; alpha++)
		{
			for (int beta = 0; beta < 26; beta++)
			{
				const std::string deciphered = decipher(origin, alpha, beta);
				if (deciphered.find("this") != std::string::npos || deciphered.find("that") != std::string::npos)
				{
					std::cout << deciphered << std::endl;
					alpha = beta = 100;
				}
			}
		}
	}
	return 0;
}
