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, "")
}

C++: #include <stdio.h>
#include <stack>

using namespace std;


//??¨??¬??????a,b????????????????????????????????¢??°
bool judge(int a, int b){
	int checkTable[26];
	for(int i=0;i<26;i++)checkTable[i] = 0;
	for(int i=0;i < 26;i++){
		if(checkTable[(a*i+b)%26] == 0){
			checkTable[(a*i+b)%26] = 1;
		}else{
			return false;
		}
	}
	return true;
}


int main(){
	int n,length,a,b;
	char buf[300],convert[26],s1,s2,s3,s4;
	bool FLG;

	scanf("%d",&n);
	getchar();
	for(int i=0;i<n;i++){
		fgets(buf,300,stdin);
		length = 0;
		FLG = false;
		//??????4?????????????????¢??????a,b?????????????????????
		for(int k=0;buf[k] != '\0';k++){
			if(buf[k] == ' '){
				if(length == 4){

					s1 = buf[k-4] - 97;
					s2 = buf[k-3] - 97;
					s3 = buf[k-2] - 97;
					s4 = buf[k-1] - 97;

					//this??§??¨??¬
					if(s1 > s4){
						a = s1 - s4;
					}else{
						a = (s1 + 26) -s4;
					}
					b = -1;
					for(int p=0;p<26;p++){
						if((19*a+p)%26==s1 && (7*a+p)%26 == s2 && (8*a+p)%26 == s3 && (18*a+p)%26 == s4){
							b = p;
							if(judge(a,b)){
								FLG = true;
								break;
							}
						}
					}
					if(FLG){
						break;
					}

					if(s1 == s4){
						//that??§??¨??¬
						a = -1;
						b = s3;
						for(int p=0;p<26;p++){
							if((19*p+b)%26==s1 && (7*p+b)%26==s2){
								a = p;
								if(judge(a,b)){
									FLG = true;
									break;
								}
							}
						}
						if(FLG){
							break;
						}
					}
				}
				length = 0;
			}else if(buf[k+1] == '\n' || buf[k+1] == '\0'){
				length++;
				if(length == 4){

					s1 = buf[k-3] - 97;
					s2 = buf[k-2] - 97;
					s3 = buf[k-1] - 97;
					s4 = buf[k] - 97;

					//this??§??¨??¬
					if(s1 > s4){
						a = s1 - s4;
					}else{
						a = (s1 + 26) -s4;
					}
					b = -1;
					for(int p=0;p<26;p++){
						if((19*a+p)%26==s1 && (7*a+p)%26 == s2 && (8*a+p)%26 == s3 && (18*a+p)%26 == s4){
							b = p;
							if(judge(a,b)){
								FLG = true;
								break;
							}
						}
					}
					if(FLG){
						break;
					}


					//that??§??¨??¬
					if(s1 == s4){
						a = -1;
						b = s3;
						for(int p=0;p<26;p++){
							if((19*p+b)%26==s1 && (19*p+b)%26 == s1 && (7*p+b)%26==s2){
								a = p;
								if(judge(a,b)){
									FLG = true;
									break;
								}
							}
						}
						if(FLG){
							break;
						}
					}
				}
				length = 0;
			}else{
				length++;
			}
		}

		//????????¨?????????
		for(int k = 0; k < 26;k++)convert[(a*k+b)%26] = k;

		for(int k=0;buf[k] != '\0';k++){
			if(buf[k]>=97 && buf[k] <= 122){
				buf[k] = convert[buf[k]-97]+97;
			}
		}
		printf("%s",buf);
	}

    return 0;
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
typedef vector <string> vs;
#define REP(i,n) for (int i=0; i<n; i++)
string A2Z="abcdefghijklmnopqrstuvwxyz";
struct affine_key{
	int a;
	int b;
};

string decode(string &L1, string &L2, string &msg){
	int n=msg.size();
	string s="";
	REP(i,n){
		char c=msg[i];
		if (c>='a' && c<='z'){
			string::size_type index=L1.find(c);
			s += L2[index];
		}else
			s += c;
	}
	return s;
}

string affine(string &msg, affine_key &key){
	string s="", s2;
	REP(i,26){
		int it=(i*key.a+key.b+26)%26;
		s += A2Z[it];
	}
	return decode(A2Z, s, msg);
}

string rot(string &msg, int a){
	if (a==0) return msg;
	while (a<0)
		a+= 26;
	a %= 26;
	string s = A2Z.substr(a)+A2Z.substr(0,a);
	return decode(A2Z, s, msg);
}

affine_key find(string &msg){
	char c0='t';
	affine_key key;
	for (int i=1; i<26; i+=2){
			key.a=i;
			key.b=0;
		string x=affine(msg, key);
		int a = c0-x[0];
		if (a<0) a += 26;
		x = rot(x,a);
		if (x=="this" || x=="that"){
			key.b=a;
			return key;
		}
	}
	key.a=-1;
	key.b=-1;
	return key;
}

vs split(const string &text, char delim=' '){
    int p1 = 0, p2 = 0;
    vs tokens;
 
    for (int i=0; i<(int)text.size(); i++)
        if (text[i] == delim){
            p2 = i;
            tokens.push_back(text.substr(p1, p2 - p1));
            p1 = p2 + 1;
        }
    tokens.push_back(text.substr(p1));
    return tokens;
}

int main(void){
	int n;
	cin>>n;
	REP(i,n){
		string msg;
		getline(cin, msg);
		vs word = split(msg);
		affine_key key;
		REP(i, word.size())
			if (word[i].size()==4){
				key = find(word[i]);
				if (key.a != -1) break;
			}
			cout<<affine(msg, key)<<endl;
	}
}

C++: #include <string>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <utility>
#include <algorithm>
#include <numeric>
#include <iostream>

using namespace std;
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

void solve(){
	string ori;
	getline(cin,ori);
	char dic[26];
	for (int b = 0; b < 26; b++){
		for (int a = 1; a < 26; a++){
			if(gcd(a,26) != 1) continue;
			string s(ori);
			for (int i = 0; i < 26; i++){
				dic[i] = (a * i + b) % 26;
			}
			for (int i = 0; i < s.length(); i++){
				if(s[i] >= 'a' && s[i] <= 'z')
					s[i] = (dic[s[i] - 'a']) + 'a';
			}
			if(s.find("that") != string::npos || s.find("this") != string::npos){
				cout << s << endl; 
				return;
			}
		}
	}
}

int main()
{
	int t; cin>>t;
	string buf; getline(cin,buf);
	while(t--){
		solve();
	}
}

C++: #include <string>
#include <iostream>
using namespace std;

int main(void) {
	int n;
	cin >> n;
	cin.ignore();
	string input;
	while(n--) {
		getline(cin, input);
		bool flag = true;

		string str = input;
		for(int a = 1; a <= 26 && flag; a++) {
			for(int b = 1; b <= 26; b++) {
				if(str.find("this") != string::npos || str.find("that") != string::npos) {
					flag = false;
					cout << str << '\n';
					break;
				} else {
					int l = str.size();
					for(int i = 0; i < l; i++) {
						if(input[i] >= 'a' && input[i] <= 'z')
							str[i] = (a * (input[i] - 'a') + b) % 26 + 'a';
					}
				}
			}
		}
	}
}

C++: #include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;

int main(){
	int n;
	char str[257] = {}, str_c[257], len;
	cin >> n;
	//getchar();
	for (int m = 0; m < n; m++){
		gets(str);
		len = strlen(str);
		//printf("%d\n", len);
		for (int i = 0; i < 26; i++){
			/*if (i % 2 == 0 || i % 13 == 0) continue;*/
			for (int j = 0; j < 26; j++){
				for (int k = 0; k <= len; k++){
					if (isalpha(str[k])){
						str[k] -= 'a';
						str_c[k] = (str[k] * i + j) % 26 + 'a';
						str[k] += 'a';
					}
					else{
						str_c[k] = str[k];
					}
				}
				if (strstr(str_c, "this") || strstr(str_c, "that")){
					printf("%s\n", str_c);
					return 0;
				}
			}
		}
	}
	return 0;
}