import std.stdio;
import std.array;
import std.conv;
import std.range;
import std.algorithm;
import std.string;
import std.numeric;
void solve(){
        string s = readln().strip();
        foreach(a;0..26){
                if(gcd(a,26)!=1) continue;
                foreach(b;0..26){
                        char[30] m;
                        foreach(i;0..26){
                                m[(i*a+b)%26] = cast(char)(i+'a');
                        }
                        auto ns = s.map!(c=>(c!=' ')?m[c-'a']:' ').array();
                        if(ns.split().any!(w=>w=="that"||w=="this")){
                                writeln(ns);
                                return;
                        }
                }
        }
}
void main() {
        int n=to!int(readln().strip());
        foreach(_;0..n)solve();
}