import std.stdio;
import std.string;
import std.conv;


void main()
{
    int n = to!int(chomp(readln()));
    for (int i = 0; i < n; i++) {
        string[] words= split(readln());
        int key = 0;
        string str;
        
        foreach (word; words) {
            key = analyzeKey(word);
            if (key != 0) break;
        }
        foreach (word; words) {
            str ~= decodeAffine(word, key / 10, key % 10);
        }

        writeln(str);
    }
}


string decodeAffine(string word, int a, int b)
{
    string output;
    
    foreach (c; word) {
        int temp = c - 'a';
        foreach (n; 0..26) {
            if (temp == (a*n + b) % 26)
                output ~= n + 'a';
        }
    }

    return output;
}


int analyzeKey(string word)
{
    for (int a = 0; ; a++) {
        //if (26 % i == 0) continue;
        for (int b = 0; ; b++) {
            //if (26 % j == 0) continue;
            string temp = encrypt(word, a, b);
            if (temp == "that" ||
                temp == "this")
                return a*10 + b;
        }
    }
    return 0;
}


string encrypt(string word, int a, int b)
{
    string output;
    
    foreach (c; word) {
        int alpha = c - 'a';
        output ~= (c*a + b) % 26 + 'a';
    }

    return output;
}