base = ord("a")

alst = [i for i in range(3, 26, 2) if i % 13]

def restore(s):

  for a in range(1,26):

    for b in range(26):

      new = "".join([chr((a * (ord(x) - base) + b) % 26 + base) if x != " " else " " for x in s])

      if "that" in new or "this" in new:

        return new



n = int(eval(input()))



for _ in range(n):

  print((restore(eval(input()))))

base = ord("a")

alst = [i for i in range(1, 26, 2) if i % 13]

def restore(s):

  for a in alst:

    for b in range(26):

      new = "".join([chr((a * (ord(x) - base) + b) % 26 + base) if x != " " else " " for x in s])

      if "that" in new or "this" in new:

        return new



n = int(eval(input()))



for _ in range(n):

  print((restore(eval(input()))))

base = ord("a")
alst = [i for i in range(3, 26, 2) if i % 13]


def restore(s):
    for a in range(1, 26):
        for b in range(26):
            new = "".join(
                [
                    chr((a * (ord(x) - base) + b) % 26 + base) if x != " " else " "
                    for x in s
                ]
            )
            if "that" in new or "this" in new:
                return new


n = int(eval(input()))
for _ in range(n):
    print((restore(eval(input()))))

base = ord("a")
alst = [i for i in range(1, 26, 2) if i % 13]


def restore(s):
    for a in alst:
        for b in range(26):
            new = "".join(
                [
                    chr((a * (ord(x) - base) + b) % 26 + base) if x != " " else " "
                    for x in s
                ]
            )
            if "that" in new or "this" in new:
                return new


n = int(eval(input()))
for _ in range(n):
    print((restore(eval(input()))))

-alst = [i for i in range(3, 26, 2) if i % 13] +alst = [i for i in range(1, 26, 2) if i % 13] -    for a in range(1, 26): +    for a in alst: