#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <complex>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    //cout << fixed << setprecision(3);

    int n;
    cin >> n;
    
    while (n--)
    {string s = "", t = "";
        while(s=="")std::getline(std::cin, s);
        t = s;
        bool found = false;
        for (int i = 3; i < 26; ++i)
        {
            s = t;
            if (i % 26 == 0 || 26 % i == 0)
                continue;

            for (int j = 1; j <= 100; ++j)
            {
                if (i % j == 0 || j % i == 0 || 26 % j == 0 || j % 26 == 0)
                    continue;

                for (int k = 0; k < (int)s.size(); ++k)
                {
                    if (s[k] >= 'a' && s[k] <= 'z')
                    {
                        s[k] = (char)('a' + (i * (s[k] - 'a') + j) % 26);
                    }
                }
                if (s.find("that") != string::npos || s.find("this") != string::npos)
                {
                    cout << s << endl;
                    found = true;
                    break;
                }
            }
            if (found)
                break;
        }
    }
    return 0;
}
