#include <bits/stdc++.h>
using namespace std;

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

int main()
{
	int n;
	scanf("%d ", &n);
	for (int c = 0; c < n; c++){
		string str;
		getline(cin, str);
		
		for (int a = 1; a <= 26; a++){
			if (gcd(a, 26) != 1) continue;
			for (int b = 0; b < 26; b++){
				string cpy(str);
				for (int i = 0; i < str.size(); i++){
					if (cpy[i] == ' ') continue;
					cpy[i] = ((cpy[i] - 'a') * a + b) % 26 + 'a';
				}
				for (int i = 0; i < (int)str.size() - 3; i++){
					string t(cpy, i, 4);
					if (t == "that" || t == "this"){
						cout << cpy << endl;
						goto BREAK;
					}
				}
			}
		}
		
		BREAK:;
	}
	
	return 0;
}