#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<complex>
#include<map>

#define f first
#define s second

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define EPS (1e-10)
using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

int  mp[26][26][26];
bool ok[26][26];

void init(){
  REP(a,26){
    REP(b,26){
      bool tmp[26] = {false};
      ok[a][b] = true;
      REP(c,26){
	int f = (a*c+b)%26;
	if(tmp[f]){
	  ok[a][b] = false;
	  break;
	}
	mp[a][b][c] = f;
      }
    }
  }
}

int main(){
  int n;
  string str;
  getline(cin, str);
  n = atoi(str.c_str());
  init();
  while(n --> 0){
    int len;
    getline(cin, str);
    len = str.size();
    REP(a,26) REP(b,26) if(ok[a][b]){
      string dec = str;
      REP(i,len)
	if(isalpha(dec[i]))
	  dec[i] = mp[a][b][dec[i]-'a'] + 'a';
      //cout << "decoded: " << dec << endl;
      if(dec.find("this") != string::npos ||
	 dec.find("that") != string::npos){
	cout << dec << endl;
	goto end;
      }
    }
  end:;
  }
  return 0;
}