#include <iostream>
#include <sstream>
using namespace std;

bool check( string S )
{
    istringstream is( S );
    string word;
    while ( is >> word ) if ( word == "this" || word == "that" ) return true;
    return false;
}

string decode( string S )
{
    int T[S.size()];
    int F[S.size()];
    for ( int i = 0; i < (int)S.size(); i++ ) T[i] = (int)( S[i] - 'a' );

    for ( int i = 1; i < 500; i++ ) {
        if ( 26 % i == 0 ) continue;
        for ( int j = 0; j < 500; j++ ) {
            for ( int k = 0; k < (int)S.size(); k++ ) {
                F[k] = ( i * T[k] + j ) % 26;
            }
            string FS( S.size(), 'a' );
            for ( int k = 0; k < (int)S.size(); k++ ) {
                if ( S[k] == ' ' ) FS[k] = ' ';
                else FS[k] += F[k];
            }
            if ( check( FS ) ) return FS;
        }
    }
    return S;
}

int main( void )
{
    int n;
    cin >> n;
    cin.ignore();
    for ( int i = 0; i < n; i++ ) {
        string line;
        getline( cin, line );
        cout << decode( line ) << endl;
    }
    return 0;
}