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

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

int main() {
  int n;
  cin >> n;
  cin.ignore();
  while(n--) {
    string s;
    getline(cin,s);
    int f = 0;
    for (int a=0;f==0;a++) {
      string buf(s);
      REP(b,26) {
        REP(i,s.length()) {
          if (s[i]!=' ') {
            buf[i] = ((s[i]-'a')*a+b)%26 + 'a';
          }
        }
        if (buf.find("that")!=-1||buf.find("this")!=-1) {
          cout << buf << endl;
          f = 1;
          break;
        }
      }
    }
  }
}