#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;




int main(){


    int n;
    string s;
    string p;
    (cin >> n).ignore();
    cin.ignore();

    while(n--){
        
        getline(cin,s);
        
        for(int i = 0;i < 26;i++){
            
            for(int j = 0;j < 26;j++){

                string t = s;

                for(int k = 0;k < t.size();k++){

                    if(islower(t[k])){
                        t[k] = ((t[k]-'a')*i + j) % 26 + 'a';
                    }

                }
                if(t.find("this") != -1 || t.find("that") != -1){
                    cout << t << endl;
                    cout << i << " " << j << endl;
                    i = j = 30;
                }

            }
        }
    }


    return 0;

}
