#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000007
#define EPS 1E-12

int n;
string tmp;

int main()
{
  cin >> n;

  while(n--){
    int alpha, beta;
    vector<string> s;
    while(cin >> tmp) s.pb(tmp);

    vrep(v, s) if((*v).size() == 4){
      bool ok = false;

      rep(a, 26) rep(b, 26){
        string word = *v;
        rep(i, 4){
          word[i] -= 'a';
          word[i] = (word[i] + 26 - b) % 26;
          word[i] = (word[i] * a) % 26;
          word[i] += 'a';
        }
        if(word == "this" || word == "that"){
          alpha = a;
          beta  = b;
          ok = true;
          break;
        }
      }
      if(ok) break;
    }

    vrep(v, s){
      tmp = *v;
      rep(i, tmp.size()){
        tmp[i] -= 'a';
        tmp[i] = (tmp[i] + 26 - beta) % 26;
        tmp[i] = (tmp[i] * alpha) % 26;
        tmp[i] += 'a';
      }
      //      cout << tmp << " ";
      cout << tmp << ((v+1)==s.end() ? "\n" : " ");
    }
    //    cout << "\b" << endl;
  }

  return 0;
}