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

char decode(int a, int b, char c)
{
  return (a * (c - 'a') + b) % 26 + 'a';
}

int main()
{
  int N;
  string str;
  cin >> N;
  cin.ignore();
  //printf("N = %d\n", N);
  for (int i = 0; i < N; i++) {
    //if (i == 0) getline(cin, str);
    getline(cin, str);

    istringstream is(str);
    string tmp;
    vector<string> token;
    while (is >> tmp) {
      token.push_back(tmp);
    }
    /*for (int j = 0; j < token.size(); j++) {
      cout << token[j] << endl;
      }*/

    for (int a = 0; a < 26; a++) {
      for (int b = 0; b < 26; b++) {
	for (int j = 0; j < token.size(); j++) {
	  tmp = token[j];
	  for (int k = 0; k < token[j].size(); k++) {
	    tmp[k] = decode(a, b, tmp[k]);
	  }
	  if (tmp == "this" || tmp == "that") {
	    for (int k = 0; k < token.size(); k++) {
	      for (int l = 0; l < token[k].size(); l++) {
		cout << decode(a, b, token[k][l]);
	      }
	      if (k == token.size() - 1) {
		cout << endl;
		goto next;
	      } else {
		cout << " ";
	      }
	    }
	  }
	}
      }
    }
  next:;
  }
}