#include <iostream>
#include <cstdio>
#include <sstream>
using namespace std;

int affine(int let,int A,int B) {
  return (A * let + B) % 26;
}

int main() {
  int n;
  string str;
  int x[257],y1;
  char y[257];
  scanf("%d\n",&n);
  for(int i=0;i<n;i++) {
    getline(cin,str);
    for(unsigned int j=0;j<str.size();j++) {
      char x1 = *str.substr(j,1).c_str();
      x[j] = (int)x1 - 97;
    }

    for(int j=1;j<27;j+=2) {
      if(j == 13) continue;
      for(int k=0;k<26;k++) {
        for(unsigned int l=0;l<str.size();l++) {
          if(0 <= x[l] && x[l] <= 25) {
            y1 = affine(x[l],j,k);
          }
          else {
            y1 = x[l];
          }
          y[l] =(char) (y1 + 97);
        }
        y[str.size()] = '\0';

        for(unsigned int l=0;l<str.size()-3;l++) {
          if(y[l] == 't') {
            if(y[l+1] == 'h') {
              if(y[l+2] == 'a') {
                if(y[l+3] == 't') {
                  cout << y << endl;
                  break;
                }
              }
              else if(y[l+2] == 'i'){
                if(y[l+3] == 's') {
                  cout << y << endl;
                  break;
                }
              }
            }
          }
        }

      }
    }

  }
}