
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
#endif

#define ITER(c)         __typeof__((c).begin())
#define FOREACH(it, c)  for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)        __typeof__((c).rbegin())
#define RFOREACH(it, c) for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)       REPEAT(i, 0, n)
#define REPEAT(i, k, n) for (int i = (k); i < (n); ++i)
#define REVREP(i, n)    for (int i = ((n)-1); i >= 0; --i)
#define FIND(c, n)      std::find((c).begin(), (c).end(), (n));
#define BSEARCH(c, n)   std::binary_search((c).begin(), (c).end(), (n))
#define LLPOW(p1,p2)    ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A)      (sizeof(A)/sizeof((A)[0]))
#define MIN(p1,p2)      (((p1)<(p2))?(p1):(p2))
#define MAX(p1,p2)      (((p1)>(p2))?(p1):(p2))
#define CIN_NO_SYNC     do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p)       fgets((p), sizeof(p), stdin)
#define CHOMP(p)        do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n') *_q = 0; } while(0)

typedef long long ll;
typedef unsigned long long ull;

#ifdef _DEBUG
#define pf printf
#define pr(n) do { cout << #n " = " << (n) << endl; } while(0)
#else
#define pf(...) /* */
#define pr(...) /* */
#endif

ll gcd(ll num1, ll num2){ return num2 == 0 ? num1: gcd(num2, num1 % num2); }

// F(r) = (ar + b) mod 26 
// r = F(r) - b + 26k) ≡ 0 (mod a)
char decode(const char ch, int n, int a, int b){
    if(!islower(ch)) return ch;
    int t = (ch - 'a') - b;
    while(t < 0 || t % a != 0) t += n;
    return 'a' + (t/a) % n;
}

int main(){
    string s;
    getline(cin, s);
    int n;
    sscanf(s.c_str(), "%d", &n);

    REP(i,n){
        getline(cin, s);
        REPEAT(j,1,26){
            if(gcd(26,j) != 1) continue;
            REP(k,26){
                string t = s;
                int len = t.size();

                REP(l,len){
                    t[l] = decode(t[l], 26, j, k);
                }

                pf("%d:%d %s\n", j, k, t.c_str());
                char buf[260];
                sprintf(buf, " %s ", t.c_str());
                if(strstr(buf, " that ") != NULL || strstr(buf, " this ") != NULL){
                    cout << t << endl;
                    goto END;
                }
            }
        }
END:;
    }

    return 0;
}