#include<iostream>
#include<cstdio>
#include<string.h>
using namespace std;

int main(){
	int n, len;
	char str[257] = {}, str_c[257];
	cin >> n;
	getchar();
	for (int m = 0; m < n; m++){
		int flag = false;
		gets(str);
		len = strlen(str);
		//printf("%d\n", len);
		for (int i = 0; i < 26; i++){
			/*if (i % 2 == 0 || i % 13 == 0) continue;*/
			for (int j = 0; j < 26; j++){
				for (int k = 0; k <= len; k++){
					if (isalpha(str[k])){
						str[k] -= 'a';
						str_c[k] = (str[k] * i + j) % 26 + 'a';
						str[k] += 'a';
					}
					else{
						str_c[k] = str[k];
					}
				}
				if (strstr(str_c, "this") || strstr(str_c, "that")){
					printf("%s\n", str_c);
					flag = true;
					break;
				}
			}
			if (flag) break;
		}
	}
	return 0;
}