#include <iostream>
#include <cstdlib>
#include <string.h>
using namespace std;

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

int main() {
  string str,sentence[256],ans;
  int x[256],afx[256],ansc[256],affans[256],anssize,size,n,alpha,beta,t;
  char convx[256],convans[256],that[5] = {'t','h','a','t','\0'},is[5] = {'t','h','i','s','\0'};
  cin >> n;
  for(int i=0;i<n;i++) {
    t = 0;
    while(cin >> str) {
      sentence[t] = str;
      t++;
      //      cout << sentence[t-1] << endl;
    }
    for(int k=0;k<t;k++) {
      size = sentence[k].size();
      //      cout << size <<endl;
      // size == 4
      if(size == 4) {
	int x[256] = {0},afx[256] = {0};
	char convx[256] = {""};
	for(int i=0;i<size;i++) { //get a word in int[]
	  x[i] = *sentence[k].substr(i,1).c_str() - 97;
	  //  cout << x[i] << endl;
	  //y[i] = x[i] + 97;
	  //cout << y[i] << endl;
	}

	
	for(int ii=0;ii<13;ii++) { //convert a word to affine word
	  for(int j=0;j<26;j++) {
	    for(int m=0;m<size;m++) {
	      if(ii != 6) {
		afx[m] = affine(x[m],2 * ii + 1,j);
		convx[m] = afx[m] +97;
	      }
	    }
	    // cout << convx << endl;
	    if((strcmp(convx,that) == 0) || (strcmp(convx,is) == 0)) {
	      //	      	      cout << "get!get!get!" << endl;
	      alpha = 2 * ii + 1;
	      beta = j;
	      goto NEXT;
	    }
	  }  
	}
     
      }
      // size == 4
    }
  NEXT:
    //    cout << "alpha = " << alpha << " beta = " << beta << endl;
    /*
      for(int m=0;m<t;m++) {
      cout << sentence[m] << endl;
      }
    */
  
    for(int m=0;m<t;m++) { // convert sentence
      ans = sentence[m];
      anssize = ans.size();
      // cout << "OK" << endl;
      for(int j=0;j<anssize;j++) {
	ansc[j] = *ans.substr(j,1).c_str() - 97;
	//	cout << ansc[j] << endl;
	affans[j] = affine(ansc[j],alpha,beta);
	//cout << affans[j] << endl;
	convans[j] = affans[j] +97;
	//	cout << convans[j] << endl;
      }
      convans[anssize] = '\0';
      if(m != t-1)
	cout << convans << " ";
      else
	cout << convans << endl;
    }
    
    
  }
}