#include<iostream>
#include<map>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>
#include<cmath>
using namespace std;
int inf = 1000000000;

char affine(char c, int a, int b){
  int x = c - 'a';
  int y = ( a * x + b ) % 26;
  char r = 'a' + y;
  return r;
}

int main(){

  int n;
  cin >> n;
  cin.ignore();
  for(int l=0; l<n; l++){
    string s;
    getline(cin, s);

    for(int i=1; i<50; i++){
      if( i % 2 == 0 || i % 13 == 0 ) continue;
      for(int j=1; j<50; j++){
        string t = "";
        for(int k=0; k<s.size(); k++){
          if( 'a' <= s[k] && s[k] <= 'z' ) t += affine(s[k], i, j);
          else t += s[k];
        }
        for(int k=0; k<t.size()-4; k++){
          if( (t[k] == 't' && t[k+1] == 'h' && t[k+2] == 'a' && t[k+3] == 't') || (t[k] == 't' && t[k+1] == 'h' && t[k+2] == 'i' && t[k+3] == 's') ) cout << t << endl;
        }
      }
    }

  }


  return 0;
}