#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <map>

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

typedef vector<int> vi;

int main()
{
	int n;
	scanf("%d%*c", &n);
	rep(i, n){
		char str[258];
		fgets(str, 258, stdin);

		set<string> words;
		stringstream stin(str);
		string tmp;
		while(stin >> tmp){
			if(tmp.size() == 4)
				words.insert(tmp);
		}

		int alpha=0, beta=0;
		bool keep = true;
		for(int i=1; keep; ++i){
			if(i%2==0 || i%13==0)
				continue;
			rep(j, 26){
				char samples[][5] = {"that", "this"};
				rep(k, 2){
					rep(l, 4) samples[k][l] = ((samples[k][l]-'a')*i+j)%26+'a';
					if(words.count(string(samples[k]))){
						alpha = i;
						beta = j;
						j=100;
						keep = false;
					}
				}
			}
		}

		map<char, char> conv;
		rep(i, 26)
			conv.insert(make_pair((i*alpha+beta)%26+'a', i+'a'));
		rep(i, strlen(str))
			putchar(isalpha(str[i]) ? conv[str[i]] : str[i]);
	}

	return 0;





// aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
// bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb


}