#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
using namespace std;
int gcd(int s)
{
	int i;
	for(i=2;i<=26;i++)
	{
		if(s%i==0&&26%i==0)break;
	}
	if(i<=26)return 1;
	else return 0;
}
int main()
{
	int n,a,b,c,i,j;
	cin >> n;
	while(getchar()!='\n');
	char str[257],tmp[257],henkan[26];
	for(i=0;i<n;i++)
	{
		fgets(str,sizeof(str),stdin);
		for(a=1;a<26;a++)
		{
			if(gcd(a))continue;
			for(b=0;b<26;b++)
			{
				memset(tmp,'\0',sizeof(tmp));
				for(c=0;c<26;c++)
				{
					henkan[(c*a+b)%26]=c;
				}
				for(j=0;str[j]!='\0'&&str[j]!='\n';j++)
				{
					if(str[j]>='a'&&str[j]<='z')
					{
						tmp[j] = henkan[str[j]-'a']+'a';
					}
					else
					{
						tmp[j] = str[j];
					}
				}
				if(strstr(tmp,"this")||strstr(tmp,"that"))
				{
					printf("%s\n",tmp);
					a=26;
					break;
				}
			}
		}
	}
	return 0;
}