Go: package main

import (
	"bufio"
	"os"
	"fmt"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		scanner.Scan()
		s := scanner.Text()
		rs := []rune(s)
		flag := false
		for b := 0; b <= 26; b++ {
			for a := 0; a <= 26; a++ {
				ans := rs
				if a%2 != 0 && a%13 != 0 {
					for j := 0; j < len(ans); j++ {
						if ans[j] > 'a' && ans[j] <= 'z' {
							ans[j] = 'a' + ('a'*(ans[j]-'a')+'b')%26
						}
					}
					sans := runeSlice2String(ans)
					if strings.Contains(sans, "that") || strings.Contains(sans, "this") {
						fmt.Println(sans)
						flag = true
						break
					}
				}
			}
			if flag {
				break
			}
		}
	}
}

func runeSlice2String(input []rune) string {
	tmp := make([]string, len(input))
	for i := 0; i < len(input); i++ {
		tmp[i] = string(input[i])
	}
	return strings.Join(tmp, "")
}

Python: for _ in[0]*int(input()):
 e=input()
 for i in range(1,26,2):
  for j in range(26):
   a=''.join([c,chr(((ord(c)-97)*i+j)%26+97)][c.islower()]for c in e)
   if'that'in a or'this'in a:print(a);break

Python: z='abcdefghijklmnopqrstuvwxyz'
e=lambda x,i,j:z[(z.index(x)*i+j)%26]
def f():
 for i in(1,3,5,7,9,11,15,17,19,21,23,25):
  for j in range(26):
   if''.join(e(c,i,j)for c in'that')in s or''.join(e(c,i,j)for c in'this')in s:return(i,j)
def g(x,y,s=0,t=1):
 q,r=x//y,x%y
 return g(y,r,t,s-q*t) if r else t
for _ in[0]*int(input()):
 s=input()
 a,b=f()
 h=g(26,a)
 print(''.join(z[h*(z.index(c)-b)%26]if c in z else c for c in s))

Python: string = 'abcdefghijklmnopqrstuvwxyz'
table = []
for i in string:
    table.append(i)

def encode(string,a,b):
    data = list(string)
    s = []
    flag = 0
    for c in data:
        try:
            i = table.index(c)
            tmp = (a*i+b)%26
            s[-1:] += table[tmp]
        except:
            s.append(' ')
    s = ''.join(s)
    return s

n = int(input())
for i in range(n):
    code = str(input())
    for a in range(1,26):
        for b in range(1,26):
            s = encode(code,a,b)
            if 'that' in s or 'this' in s:
                print(s)

Python: z='abcdefghijklmnopqrstuvwxyz'
e=lambda x,i,j:z[(z.index(x)*i+j)%26]
def f():
 for i in range(1,26,2):
  for j in range(26):
   if''.join(e(c,i,j)for c in'that')in s or''.join(e(c,i,j)for c in'this')in s:return(i,j)
for _ in[0]*int(input()):
 s=input()
 print(s.translate(str.maketrans(''.join(e(c,*f())for c in z),z)))

Python: n=int(input())

def GCD(a,b):
    if min(a,b)==0:
        return max(a,b)
    else:
        return GCD(min(a,b),max(a,b)%min(a,b))

def affine(a,b,word):
    retval=""
    for w in word:
        retval+=chr(ord('a')+((ord(w)-ord('a'))*a+b)%26)
    return retval

for i in range(n):
    encrypted=input().split(" ")
    for a in range(1,27):
        for b in range(1,27):
            if GCD(a,26)!=1:
                continue
            plain=[affine(a,b,s) for s in encrypted]
            if ("this" in plain) or ("that" in plain):
                print(" ".join(plain))
                break

Python: def affine(x, a, b):
    result = []
    for i in range(len(x)):
        c = chr((a * (ord(x[i])-97) + b) % 26 + 97)
        result.append(c)

    return ''.join(result)


def decode_key(a, b):
    key = "abcdefghijklmnopqrstuvwxyz"
    result = []
    for i in range(len(key)):
        result.append(affine(key[i], a, b))
    return ''.join(result)


a = [1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25]
n = int(input())
for i in range(n):
    ai = 0
    b = 0
    line = input()
    words = line.split()
    for i in range(26):
        for j in range(len(a)):
            if affine('that', a[j], i) in words:
                ai = j
                b = i
            if affine('this', a[j], i) in words:
                ai = j
                b = i
        if ai and b:
            break

    line = line.translate(str.maketrans(decode_key(a[ai], b), "abcdefghijklmnopqrstuvwxyz"))
    print(line)

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

Python: 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(input()):print(f(input()))

Python: z='abcdefghijklmnopqrstuvwxyz'
e=lambda x,i,j:z[(z.index(x)*i+j)%26]
def f():
 for i in range(1,26,2):
  for j in range(26):
   if''.join(e(c,i,j)for c in'that')in s or''.join(e(c,i,j)for c in'this')in s:return(i,j)
def g(x,y,s=0,t=1):
 q,r=x//y,x%y
 return g(y,r,t,s-q*t) if r else t
for _ in[0]*int(input()):
 s=input()
 a,b=f()
 h=g(26,a)
 print(''.join(z[h*(z.index(c)-b)%26]if c in z else c for c in s))

Python: for _ in range(int(input())):
    s=input()
    for i in range(1,27,2):
        for j in range(27):
            a=[]
            for k in range(len(s)):
                if s[k].islower():a+=chr(((ord(s[k])-97)*i+j)%26+97)
                else:a+=s[k]
            a=''.join(a)
            if 'this' in a or 'that' in a:print(a)

Python: 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(input()):print(f(input()))

Python: from itertools import product

alphabet = 'abcdefghijklmnopqrstuvwxyz'

def decrypt(s):
    for a in range(1, 26, 2):
        if a == 13: continue
        for b in range(26):
            x = ''.join(chr(ord('a') + (a * i + b) % 26) for i in range(26))
            t = s.translate(str.maketrans(x, alphabet))
            if 'this' in t or 'that' in t:
                return t

n = int(input())
for i in range(n):
    s = input()
    print(decrypt(s))

Python: from math import gcd
def unzip(strlist,a,b):
    ret = []
    for word in strlist:
        tmp = ""
        for i in range(len(word)):
            tmp += chr(((ord(word[i])-97)*a+b)%26+97)
        ret.append(tmp)
    return ret

n = int(input())
for _ in range(n):
    instr = input().split()
    for a in range(1,26):
        if gcd(1,26)!=1 : continue
        for b in range(26):
            if "this" in unzip(instr, a, b):
                print(" ".join(unzip(instr, a, b)))
            elif "that" in unzip(instr, a, b):
                print(" ".join(unzip(instr, a, b)))

Python: for _ in[0]*int(input()):
 e=input()
 for i in range(1,26,2):
  for j in range(26):
   a=''.join([c,chr(((ord(c)-97)*i+j)%26+97)][c.islower()]for c in e)
   if('that'or'this')in a:print(a);break

Python: z='abcdefghijklmnopqrstuvwxyz'
e=lambda x,i,j:z[(z.index(x)*i+j)%26]
def f():
 for i in range(1,26,2):
  for j in range(26):
   if''.join(e(c,i,j)for c in'that')in s or''.join(e(c,i,j)for c in'this')in s:return(i,j)
for _ in[0]*int(input()):
 s=input()
 k=f()
 a=''.join(e(c,*k)for c in z)
 t=str.maketrans(a,z)
 print(s.translate(t))

Python: cv=lambda r,a,b:chr(((ord(r)-97)*a+b)%26+97) if 97<=ord(r)<=122 else r
cv2=lambda x:cv(x,i,j) if 97<=ord(x)<=122 else cv(x.lower(),i,j).upper()

for _ in range(int(input())):
    l=input()
    for i in [1,3,5,7,9,11,15,17,19,21,23,25]:
        for j in range(1,27):
            s="".join(map(cv2,l))
            if "this" in s or "that" in s:
                break
        if "this" in s or "that" in s:
            break
    print(s)

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