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

char getDigit(int alpha, int beta, char y)
{
    int buff;
    y = y - 'a';
    buff = (alpha * y + beta) % 26;
    buff += 'a';
    return (char) buff;
}

int main()
{
    int n;
    string context;

    cin >> n;

    for(int i =0; i < n; i++)
    {
        cin >> context;
        while(1)
        {
            for(int alpha = 0; alpha <= 50; alpha++)
            for(int beta = 0; beta <= 26; beta++)
            {
                for(int j = 0; j < context.size(); j++) context[j] = getDigit(alpha, beta, context[j]);
                if(string::npos != context.find("that", 0)) break;
                if(string::npos != context.find("this", 0)) break;
            }
        }
        cout << context << endl;
    }


}