#include <iostream>
#include <string>
#define rep(i) for(I64 i=0;;++i)
#define repn(i,n) for(I64 i=0;i<(n);++(i))
using namespace std;

bool coprime(int a, int b){
	int r, temp;
	if(a < b){
		temp = a;
		a = b;
		b = temp;
	}
	do{
		r = a % b;
		a = b;
		b = r;
	}while(r);
	if(a == 1) return true;
	else return false;
}

int main(){
	char t[26];

	int n;
	cin >> n;

	scanf("%*c");

	repn(i, n){
		string input;
		getline(cin, input);
		int len = input.size();

		bool flag = false;
		rep(a){
			if(coprime(26, a+1)){
				repn(b, 26){
					string res = "";
					repn(r, 26){
						t[r] = ((a+1) * r + b) % 26 + 'a';
					}
					repn(j, len){
						if(input[j] == ' ') res += ' ';
						else{
							repn(k, 26){
								if(input[j] == t[k]){
									res += k + 'a';
									break;
								}
							}
						}
					}
					if(res.find("this") != string::npos || res.find("that") != string::npos){
						cout << res << endl;
						flag = true;
						break;
					}
				}
				if(flag) break;
			}
			if(flag) break;
		}
	}
}