#include <iostream>
#include <cstring>
using namespace std;

int main(){
	int gomi;
	cin >> gomi;
	cin.ignore();
	string str;
	while(getline(cin,str)){
		bool hata = false;
		int a = 0, b = 0;
		int p=-1,q;
		for(int i = 0; i < str.size()+1; i++){
			if(str[i] == ' ' || i == str.size()){
				q = i;
				if(q-p == 5){
					for(int j = 1; j < 26; j++){
						if(j%2==0 || j == 13){
							continue;
						}
						if((j*('t'-'a')-(str[i-4]-'a')-j*('h'-'a')+(str[i-3]-'a'))%26 == 0){
							if((j*('h'-'a')-(str[i-3]-'a')-j*('a'-'a')+(str[i-2]-'a'))%26 == 0 && (j*('a'-'a')-(str[i-2]-'a')-j*('t'-'a')+(str[i-1]-'a'))%26 == 0 ){
								a = j;
								b = ((str[i-4]-'a')-j*('t'-'a'))%26;
								if(b < 0){
									b += 26;
								}
								hata = true;
								break;
							}
							else if((j*('h'-'a')-(str[i-3]-'a')-j*('i'-'a')+(str[i-2]-'a'))%26 == 0 && (j*('i'-'a')-(str[i-2]-'a')-j*('s'-'a')+(str[i-1]-'a'))%26 == 0 ){
								a = j;
								b = ((str[i-4]-'a')-j*('t'-'a'))%26;
								if(b < 0){
									b += 26;
								}
								hata = true;
								break;
							}
						}
					}
				}
				p = q;
			}
			if(hata == true){
				break;
			}
		}
		for(int i = 0; i < str.size(); i++){
			if(str[i] != ' '){
				for(int j = 0; j < 26; j++){
					if(str[i]-'a' == (j*a+b)%26){
						str[i] = 'a'+j;
						break;
					}
				}
			}
		}
		cout << str << endl;
	}
}