#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> P;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
int gcd(int m,int n){
  return n?gcd(n,m%n):m;
}
int main(void){
  int n;
  cin>>n;
  cin.ignore();
  while(n--){
    string line;
    stringstream ss;
    getline(cin,line);
    int decode[26];
    char t1[] = "that";
    char t2[] = "this";
    char test[] = "that";
    bool finde = false;
    for(int a = 3; a<=1126; a++){
      if(a==1126) puts("a");
      if(gcd(26,a)!=1) continue; 
      for(int b=0; b<26; b++){

        for(int i=0; i<26; i++){
          decode[i] = (a*i+b)%26;
        }
        
        for(int i=0;i<4; i++){
          test[i] = 'a' + decode[t1[i]-'a'];
        }
        if(line.find(test)!=string::npos){
          //cout<<test<<endl;
          finde = true;
          break;
        }
        for(int i=0;i<4; i++){
          test[i] = 'a' + decode[t2[i]-'a'];
        }
        if(line.find(test)!=string::npos){
          //cout<<test<<endl;
          finde = true;
          break;
        }
      }
      if(finde) break;
    }
    ss<<line;
    bool f = false;
    while(ss>>line){
      if(f) cout<<" ";
      f = true;
      for(int i=0;i<(int)line.size();i++){
        for(int j=0; j<26; j++){
          if(decode[j]+'a'==line[i]){
            line[i] = 'a' + j;
            break;
          }
        }
      }
      cout<<line;
    }
    cout<<endl;
    //for(int i=0;i<26; i++) cout<<decode[i]<<" ";
  } 
  return 0;
}