#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int gcd(int x, int y);

int main()
{
    int n;
    string s;
    cin >> n;
    while (getline(cin, s))
    {
        bool is_found = false;
        for(int alpha=1; alpha<=26; alpha++)
        {
            if(gcd(alpha, 26) !=1)
            {
                continue;
            }
            for(int beta=0; beta<26; beta++)
            {
                string ans = s;
                for(int i=0; i<ans.size(); i++)
                {
                    if(ans[i] >= 'a' && ans[i] <= 'z')
                    {
                        ans[i] = 'a' + (alpha * (ans[i] -'a') + beta) % 26;
                    }
                    else
                    {

                    }
                }
                if( ans.find("this") != std::string::npos
                 || ans.find("that") != std::string::npos)
                {
                    cout << ans << endl;
                    is_found = true;
                    break;
                }
            }
            if(is_found)
            {
                break;
            }
        }
    }
    return 0;
}

int gcd(int x, int y)
{
    if(x < y)
    {
        swap(x, y);
    }
    while(y > 0)
    {
        int r = x % y;
        x = y;
        y = r;
    }
    return x;
}