# -*- coding: utf-8 -*-



import sys

import os

import math





N = int(eval(input()))

alphabet = 'abcdefghijklmnopqrstuvwxyz'



def encode(s, alpha, beta):

    t = []

    for c in s:

        if c == ' ':

            t.append(c)

        else:

            gamma = ord(c) - 97

            v = (alpha * gamma + beta) % 26

            w = alphabet[v]

            t.append(w)

    return ''.join(t)





for i in range(N):

    s = input().strip()



    for a in range(26):

        for b in range(26):

            encoded = encode(s, a, b)

            if 'that' in encoded or 'this' in encoded:

                print(encoded)
# -*- coding: utf-8 -*-



import sys

import os

import math



N = int(eval(input()))

alphabet = 'abcdefghijklmnopqrstuvwxyz'



def encode(s, alpha, beta):

    t = []

    for c in s:

        if c == ' ':

            t.append(c)

        else:

            gamma = ord(c) - 97

            v = (alpha * gamma + beta) % 26

            w = alphabet[v]

            t.append(w)

    return ''.join(t)





for i in range(N):

    s = input().strip()

    

    for a in range(0, 26):

        for b in range(0, 26):

            encoded_this = encode('this', a, b)

            encoded_that = encode('that', a, b)

            if encoded_this in s or encoded_that in s:

                encoded_alphabet = encode(alphabet, a, b)

                table = str.maketrans(encoded_alphabet, alphabet)

                dst = s.translate(table)

                print(dst)
# -*- coding: utf-8 -*-
import sys
import os
import math

N = int(eval(input()))
alphabet = "abcdefghijklmnopqrstuvwxyz"


def encode(s, alpha, beta):
    t = []
    for c in s:
        if c == " ":
            t.append(c)
        else:
            gamma = ord(c) - 97
            v = (alpha * gamma + beta) % 26
            w = alphabet[v]
            t.append(w)
    return "".join(t)


for i in range(N):
    s = input().strip()
    for a in range(26):
        for b in range(26):
            encoded = encode(s, a, b)
            if "that" in encoded or "this" in encoded:
                print(encoded)

# -*- coding: utf-8 -*-
import sys
import os
import math

N = int(eval(input()))
alphabet = "abcdefghijklmnopqrstuvwxyz"


def encode(s, alpha, beta):
    t = []
    for c in s:
        if c == " ":
            t.append(c)
        else:
            gamma = ord(c) - 97
            v = (alpha * gamma + beta) % 26
            w = alphabet[v]
            t.append(w)
    return "".join(t)


for i in range(N):
    s = input().strip()
    for a in range(0, 26):
        for b in range(0, 26):
            encoded_this = encode("this", a, b)
            encoded_that = encode("that", a, b)
            if encoded_this in s or encoded_that in s:
                encoded_alphabet = encode(alphabet, a, b)
                table = str.maketrans(encoded_alphabet, alphabet)
                dst = s.translate(table)
                print(dst)

-    for a in range(26): -        for b in range(26): -            encoded = encode(s, a, b) -            if "that" in encoded or "this" in encoded: -                print(encoded) +    for a in range(0, 26): +        for b in range(0, 26): +            encoded_this = encode("this", a, b) +            encoded_that = encode("that", a, b) +            if encoded_this in s or encoded_that in s: +                encoded_alphabet = encode(alphabet, a, b) +                table = str.maketrans(encoded_alphabet, alphabet) +                dst = s.translate(table) +                print(dst)