#include <cstdio>
#include <cstring>
#include <string>
using namespace std;

int n;
char buf[1000];
int invmod[] = {0, 1, 0, 9, 0, 21, 0, 15, 0, 3, 0, 19, 0, 0, 0, 7, 0, 23, 0, 11, 0, 5, 0, 17, 0, 25};

string decrypt(string s, int a, int b) {
  string ret;

  if (invmod[a]*a%26 != 1) return "";
   
  for (int i=0; i<s.size(); i++) {
    if (s[i] == ' ') ret += ' ';
    else {
      int k = (s[i]-'a'-b+26)%26;
      ret += 'a'+k*invmod[a]%26;
    }
  }

  return ret;
}

void process() {
  fgets(buf, sizeof(buf), stdin);
  char *sp = strchr(buf, '\n');
  if (sp != NULL) *sp = '\0';

  for (int i=0; i<26; i++) {
    for (int j=0; j<26; j++) {
      string decoded = decrypt(buf, i, j);
      if (decoded.find("that") != string::npos) {
        printf("%s\n", decoded.c_str());
        return;
      }

      if (decoded.find("this") != string::npos) {
        printf("%s\n", decoded.c_str());
        return;
      }
    }
  }
}

int main() {
  scanf("%d ", &n);
  while (n--) {
    process();
  }
}