var print = console.log; // like python
var input_lines; // ?¨??????\????????????????????????????????????

function PreMain(input) {
    input_lines = input.split("\n");
    var f = function () {
        return input_lines.shift();
    };
    Main(f);
}

function IL(min1Flg) {
    var s = input_lines.shift().split(' ');
    var offset = min1Flg ? -1 : 0;
    var res = [];
    for (var i = 0; i < s.length; i++) {
        res.push(parseInt(s[i]));
    }
    return res;
}

/**
 * @return {number}
 */
Array.prototype.SUM = function SUM() {
    var sum = 0;
    this.forEach(function (elm) {
        sum += elm;
    });
    return sum;
};

/**
 * @return {string}
 */
Array.prototype.Format = function Format(split) {
    if (split === undefined) {
        split = " ";
    }
    return this.join(split);
};

Array.prototype.Copy = function Copy() {
    return [].concat(this);
};

/***
 * ??????Sort
 * <Array>.sort?????¨???(?????????)???????????????????????¨????????¨???
 * ??°????????????????????§?????°????????????????????????????????´??????????????????????????¨?????????
 * @constructor
 */
Array.prototype.Sort = function Sort() {
    this.sort(function (a, b) {
        if (a < b) return -1;
        if (a > b) return 1;
        return 0;
    });
};

/*

(((???????????)??? ?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

*/

function range(i, n) {
    var res = [];
    for (; i < n; i++) {
        res.push(i);
    }
    return res;
}

function get_pattern() {

    var pat = {};
    range(1, 26).forEach(function (a) {
        if (a % 2 === 0 || a % 13 === 0) {
            return;
        }
        var acode = 'a'.charCodeAt(0);
        for (var b = 0; b < 26; b++) {
            var converted_alphabet = '';
            for (var c = 0; c < 26; c++) {
                converted_alphabet += String.fromCharCode(((a * c + b) % 26) + acode);
            }
            var tmp = '';
            var tmp2 = '';

            for (var i = 0; i < 4; i++) {
                var x = 'this'.charCodeAt(i) - acode;
                tmp += converted_alphabet.charAt(x);
                var y = 'that'.charCodeAt(i) - acode;
                tmp2 += converted_alphabet.charAt(y);
            }
            pat[tmp] = converted_alphabet;
            pat[tmp2] = converted_alphabet;
        }
    });
    return pat;
}

function get_foo(str, str2) {
    var acode = 'a'.charCodeAt(0);
    var res = '';
    for (var i = 0; i < str.length; i++) {
        if (str.charAt(i) === ' ') {
            res += ' ';
        } else {
            res += String.fromCharCode(str2.indexOf(str.charAt(i)) + acode);
        }
    }
    return res;
}

function Main(input) {
    var n = parseInt(input());
    var p = get_pattern();
    var str2;
    for (var j = 0; j < n; j++) {
        var str_org = input();
        var str = str_org.split(' ');
        for (var i = 0; i < str.length; i++) {
            if (p.hasOwnProperty(str[i])) {
                str2 = p[str[i]];
                break;
            }
        }
        print(get_foo(str_org,str2));
    }
}

 PreMain(require("fs").readFileSync("/dev/stdin", "utf8"));
//PreMain(require("fs").readFileSync("input.txt", "utf8"));