#include<iostream>
#include<string>
#include<vector>
#include<sstream>

using namespace std;

string conv(int a, int b, string str)
{
	string line=str;
	for(int i=0;i<line.length();i++)
	{
		if('a'<=line.at(i)&&line.at(i)<='z')
		{
			line.at(i)-='a';
			for(int y=0;y<26;y++)
			{
				if((a*y+b)%26==line.at(i))
				{
					line.at(i)=y+'a';
					break;
				}
			}
		}
	}
	return line;
}

string solve(string line)
{
	for(int b=0;b<26;b++)
	{
		for(int a=1;a<100;a++)
		{
			if(a%2!=0&&a%13!=0)
			{
				string ans=conv(a,b,line);
				if(ans.find("that")!=string::npos||ans.find("this")!=string::npos)
				{
					return ans;
				}
			}
		}
	}
	return line;
}

int main(void)
{
	int n;
	string line;
	getline(cin,line);
	stringstream ss(line);
	ss>>n;
	for(int i=0;i<n;i++)
	{
		getline(cin,line);
		cout<<solve(line)<<endl;
	}
}