#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <vector>
#include <cstdio>

using namespace std;

int a,b;
vector<int> That;
vector<int> This;

vector<char> word;
vector<int> iword;

void init(){
	That.push_back(19);
	That.push_back(7);
	That.push_back(0);
	That.push_back(19);
	This.push_back(19);
	This.push_back(7);
	This.push_back(8);
	This.push_back(18);
}

bool ab(){
	for(int i=2; i<=26; i++){
		if(26%i==0){
			if(a%i==0)return false;
		}
	}
	return true;
}

int f(int c){
	return (a*c+b)%26;
}

int change(char c){
	if(c>='a'&&c<='z')return c-'a';
	return -1;
}
void getWord(string s,int *n){
	word.clear();
	for(; *n<s.size(); *n+=1){
		// cout<<"s:"<<s<<endl;
		// cout<<"j:"<<*n<<" "<<s.at(*n)<<endl;
		if(s.at(*n)==' '||s.at(*n)=='\0'){
			*n+=1;
			return;
		}
		//cout<<"j:"<<*n<<endl;
		word.push_back(s.at(*n));
	}
}

void getIword(){
	iword.clear();
	for(int i=0; i<word.size(); i++){
		iword.push_back(f(change(word.at(i))));
	}
}


char changeC(int i){
	return i+'a';
}

int main(){
	int n;
	string s;
	init();
	cin>>n;
	cin.ignore();
	//cout<<n<<endl;
	for(int i=0; i<n; i++){
		getline(cin,s);
		//cout<<s<<endl;
		bool flag=false;
		for(a=0; a<26; a++){
			for(b=0; b<26; b++){
				if(ab()){
					int j=0;
					while(j<s.size()){
						//<<j<<endl;
						getWord(s,&j);
						if(word.size()==4){
							getIword();
							if(iword==This||iword==That){
								// cout<<"a:"<<a<<" b:"<<b<<endl;
								// cout<<"iword:";
								// for(int i=0; i<iword.size(); i++){
								// 	cout<<changeC(iword.at(i));
								// }
								//cout<<endl;
								flag=true;
								break;
							}
						}
					}
				}
				if(flag)break;
			}
			if(flag)break;
		}
		for(int i=0; i<s.size(); i++){
			if(change(s.at(i))==-1)cout<<' ';
			else cout<<changeC(f(change(s.at(i))));
		}
		cout<<endl;
		//cout<<"a:"<<a<<" b:"<<b<<endl;
	}
	

}