#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(c,i) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

string decrypt(const string& c,int a,int b)
{
	int table[26];
	rep(i,26)
		table[(a*i+b)%26]=i;
	string res=c;
	rep(i,c.size())
		if(islower(c[i]))
			res[i]=table[c[i]-'a']+'a';
	return res;
}

int main()
{
	int n;
	cin>>n;
	cin.get();
	rep(loop,n){
		string c;
		getline(cin,c);
		repi(i,1,26){
			if(i==2 || i==13)
				continue;
			rep(j,26){
				string d=decrypt(c,i,j);
				string temp=" "+d+" ";
				if(temp.find(" that ")!=string::npos || temp.find(" this ")!=string::npos){
					cout<<d<<endl;
					goto end;
				}
			}
		}
		end:
		;
	}
	
	return 0;
}