#include <iostream>
#include <map>
#include <algorithm>
#include <cstdio>
#include <string>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;


int main(void){

int N,w;
string inl,wks,ans;
	cin >> N;

	rep(i,100) w +=i;
	rep(i,N){
		getline(cin,wks);
		rep(j,100) rep(k,26){
			inl = wks;
            for(int m=0; m < inl.size(); m++){
                if(inl[m] >= 'a' && inl[m] <= 'z')
            		inl[m]=( j * (inl[m]-'a') +k) %26 + 'a';
            }
//			if(j<2) cout << j <<"-" << k << ": " << inl << endl;
			if(inl.find("this") != string::npos 
            	|| inl.find("that") != string::npos ){
				ans = inl;
            	break;
            	
            }
		}
		cout << ans << endl;
	}	
	
	return 0;
	
	
}