import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;
import std.numeric;

void solve()
{
    char['z'+1] t; t[' ']=' ';
    auto s = readln().chomp();
    foreach(a;1..26)
        if(gcd(a,26)!=1) continue;
        else
            foreach(b;0..26)
            {
                foreach(i,v;iota(26).map!(y=>(a*y+b)%26).array())
                    t[v+'a']=cast(char)(i+'a');
                auto r = s.map!(c=>t[c]).array();
                if(r.split().any!(w=>w=="that"||w=="this"))
                { writeln(r);return; }
            }
}

void main()
{
    foreach(_;0..readln().chomp().to!int()) solve();
}