#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <iostream>


using namespace std;


int gcd(int a, int b)
{
	if (a < b)
		return gcd(b, a);
	if (b == 0)
		return a;

	return gcd(b, a%b);
}

int main()
{
	int n;
	scanf("%d ", &n);
	for (int ww = 0; ww < n; ++ww)
	{
		char enc[1<<8+1];
		fgets(enc, sizeof(enc), stdin);
		enc[strlen(enc)-1] = '\0';

		bool isFound = false;
		for (int a = 3; ; ++a)
		{
			if (gcd(a, 26) != 1)
				continue;

			int da[26];
			for (int i = 0; i < 26; ++i)
				da[(a*i)%26] = i;
			for (int b = 0; b < 25; ++b)
			{
				int dt[26];
				for (int i = 0; i < 26; ++i)
					dt[i] = da[(i+b)%26];

				char dec[1<<8+1];
				for (int i = 0; enc[i] != '\0'; ++i)
				{
					char c;
					if (islower(enc[i]))
						c = dt[enc[i]-'a'] + 'a';
					else
						c = enc[i];
					
					dec[i] = c;
				}
				dec[strlen(enc)] = '\0';

				if (strstr(dec, "that") || strstr(dec, "this"))
				{
					puts(dec);
					isFound = true;
					break;
				}
			}
			if (isFound)
				break;
		}
	}

	return 0;
}