z='abcdefghijklmnopqrstuvwxyz'

for _ in[0]*int(eval(input())):

 e=eval(input())

 for i in range(1,26,2):

  for j in range(26):

   a=''

   for c in e:

    a+=z[(z.index(c)*i+j)%26]if c in z else c

   if'that'in a or'this'in a:print(a);break

z='abcdefghijklmnopqrstuvwxyz'

for _ in[0]*int(eval(input())):

 e=eval(input())

 for i in range(1,26,2):

  for j in range(26):

   a=''.join(z[(z.index(c)*i+j)%26]if c in z else c for c in e)

   if'that'in a or'this'in a:print(a);break

z = "abcdefghijklmnopqrstuvwxyz"
for _ in [0] * int(eval(input())):
    e = eval(input())
    for i in range(1, 26, 2):
        for j in range(26):
            a = ""
            for c in e:
                a += z[(z.index(c) * i + j) % 26] if c in z else c
            if "that" in a or "this" in a:
                print(a)
                break

z = "abcdefghijklmnopqrstuvwxyz"
for _ in [0] * int(eval(input())):
    e = eval(input())
    for i in range(1, 26, 2):
        for j in range(26):
            a = "".join(z[(z.index(c) * i + j) % 26] if c in z else c for c in e)
            if "that" in a or "this" in a:
                print(a)
                break

-            a = "" -            for c in e: -                a += z[(z.index(c) * i + j) % 26] if c in z else c +            a = "".join(z[(z.index(c) * i + j) % 26] if c in z else c for c in e)