import std.stdio,std.string,std.conv,std.ascii;

int main()
{
	int num = readln.chomp.to!int;
	while(num--)
	{
		string s = readln.chomp;
		string _s = s;
		bool flag = true;

		foreach(x;1..26)
		{
			foreach(y;1..26)
			{
				if(_s.indexOf("that") + _s.indexOf("this") == -2)
				{
					string temp;
					foreach(i;0..s.length)
					{
						if(s[i].isAlpha)
						{
							temp ~= ((((s[i] - 'a')*x)+y)%26)+'a';
						}
						else
						{
							temp ~= s[i];
						}
					}
					_s = temp;
				}
				else
				{
					_s.writeln;
					flag = false;
					break;
				}
			}
			if(!flag) break;
		}
	}
	return 0;
}