#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cctype>
using namespace std;

int conv(int ch, int a, int b) {
  if ( !isalpha(ch) ) return ch;
  int n = ch - 'a';
  return (char)('a' + (a * n + b) % 26);
}

int valid(int a, int b) {
  int count[26] = {};
  for(int n = 0; n < 26; n++) {
    if ( ++count[conv(n + 'a', a, b) - 'a'] >= 2 )
      return 0;
  }
  return 1;
}

int check(string line, int a, int b) {
  if ( !valid(a, b) ) return 0;

  for(int i = 0; i < (int)line.size(); i++)
    line[i] = conv(line[i], a, b);

  return line.find("that") != string::npos ||
    line.find("this") != string::npos;
}

int main() {
  int T; cin >> T >> ws;
  while(T--) {
    string line;
    getline(cin, line);

    for(int a = 0; a < 26; a++)
      for(int b = 0; b < 26; b++) {
        int res = check(line, a, b);
        if ( res ) {
          for(int i = 0; i < (int)line.size(); i++)
            cout << (char)conv(line[i], a, b);
          cout << endl;
        }
      }
  }
  return 0;
}