#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
#define rep2(x,from,to) for(int x = (from); x < (to); ++(x))
#define rep(x,to) rep2(x,0,to) 
int c[26];
bool ch(int x) {
	int a = 26, b = x;
	if(b < a) swap(a, b);
	while(a) {
		int t = b / a;
		swap(b -= t * a, a);
	}
	if(b != 1) return false;
	else {
		rep(i,26) {
			c[i] = (x * i) % 26;
		}
		return true;
	}
}
int main() {
	int n;
	char str[260];
	scanf("%d\n", &n);
	while(n--) {
		gets(str);
		string s = str;
		int len = s.length();
		bool f = 0;
		rep2(i,1,10000) {
			if(ch(i)) {
				rep(k,26) {
					char ns[260];
					rep(j,len) {
						if(islower(str[j])) {
							int b = str[j] - 'a';
							ns[j] = (char) ((c[b] + k) % 26 + 'a');
						} else {
							ns[j] = str[j];
						}
					}
					rep(j,len) {
						if(ns[j] == 't' && ns[j+1] == 'h' && ns[j+2] == 'a' && ns[j+3] == 't' ||
							ns[j] == 't' && ns[j+1] == 'h' && ns[j+2] == 'i' && ns[j+3] == 's') {
							f = 1;
							break;
						}
					}
					if(f) {
						rep(j,len) {
							cout << ns[j];
						}
						cout << endl;
						break;
					}
				}
			}
			if(f) break;
		}
	}
	return 0;
}