#include<iostream>
#include<string>

int main()
{
	int n;
	std::cin >> n;

	while( n-- )
	{
		std::string s;
		std::cin.ignore();
		std::getline( std::cin, s );

		std::string t( s.size(), ' ' );

		for( int a = 1; a < 26; a += 2 )
		{
			if( a == 13 )
				continue;

			for( int b = 0; b < 26; ++b )
			{
				for( int i = 0; i != s.size(); ++i )
				{
					if( s[i] >= 'a' && s[i] <= 'z' )
					{
						int g = s[i] - 'a';

						t[i] = ( a * g + b ) % 26 + 'a';
					}
				}

				if( t.find( "this" ) != std::string::npos || t.find( "that" ) != std::string::npos )
					goto end;
			}
		}

end:;

		std::cout << t;
	}

	return 0;
}