#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <algorithm>
using namespace std;

#define rep(i,n) for((i)=0;(i)<(int)n;(i)++)
#define foreach(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)

int n;
const int MAX_N = 100000;
string in;
vector<int> v;
bool sieve[MAX_N];

inline char F(int alpha, int beta, char gamma) {
  return 'a'+((alpha*(gamma-'a')+beta)%26);
}

int main() {
  int i, j, k, l;
  fill(sieve, sieve + MAX_N, true);
  for (i = 2; i < MAX_N; i+=2) sieve[i] = false;
  for (i = 3; i < MAX_N; i+=2) if (sieve[i]) {
    v.push_back(i);
    for (j = i+i; j < MAX_N; j+=i) {
      sieve[j] = false;
    }
  }
  
  cin >> n;
  cin.ignore();
  int vsz = v.size();
  rep(i,n) {
    getline(cin, in);
    int insz = in.size();
    rep(j,vsz) rep(k,26) {
      string cipher;
      rep(l,insz) {
        if (in[l] == ' ') {
          cipher += ' ';
          continue;
        }
        cipher += F(v[j], k, in[l]);
      }
      if (cipher.find("that") != -1 || cipher.find("this") != -1) {
        cout << cipher << endl;
        j = vsz;
        k = 26;
      }
    }
  }
  return 0;
}