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'

def f(x):

 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 x)

   if'that'in a or'this'in a:return a

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

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"


def f(x):
    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 x)
            if "that" in a or "this" in a:
                return a


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

-for _ in [0] * int(eval(input())): -    e = eval(input()) + + +def f(x): -            a = "".join(z[(z.index(c) * i + j) % 26] if c in z else c for c in e) +            a = "".join(z[(z.index(c) * i + j) % 26] if c in z else c for c in x) -                print(a) -                break +                return a + + +for _ in [0] * int(eval(input())): +    print((f(eval(input()))))