#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#define rep_to(a,i,n) for(i=a;i<n;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define rep_r(i,n) for(i=n-1;i>=0;i--)
#define debug_i(x) printf("x:%d\n",x)
#define debug_s(str) printf("str:%s\n",str)
#define debug_c(c) printf("c:%c\n",c) 

int main()
{
	int i,j,k,l,z;
	int n=0;
	char str[257][257]={};
	char str2[257][257]={};
	char *p;
	int ans,count=1;
	int flag=0;
	scanf("%d\n",&n);

	rep(z,n)
	{
		fgets(str[0],sizeof(str[0]),stdin);
		str[0][strlen(str[0])-1]='\0';
		p=strtok(str[0]," ");
		strncpy(str[0],p,strlen(p));
		while(p!=NULL)
		{
			p=strtok(NULL," ");
			if(p!=NULL)
			{
				strncpy(str[count],p,strlen(p));
				count++;
			}
		}
		while(1)
		{
			rep_to(1,j,26)
			{
				rep(k,count)
				{
					rep(l,strlen(str[k]))
					{
						str2[k][l]=(i*(str[k][l]-97)+j)%26+97;
					}
				}
				rep(k,count)
				{
					if(strstr(str2[k],"that")!=NULL)flag=1;
					else if(strstr(str2[k],"this")!=NULL)flag=1;
				}
				if(flag==1)break;
			}
			if(flag==1)break;
			i++;
		}
		rep(i,count)
		{
			if(count-1!=i)printf("%s ",str2[i]);
			else printf("%s",str2[i]);
		}
		printf("\n");
		flag=0;
		count=1;
	}
	return 0;
}