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 <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

string change(string s,int a,int b){
	string ret(s);
	rep(i,0,ret.size()){
		int y=ret[i]-'a';
		if(y>=0 && y<26){
			y=(a*y+b)%26;
			ret[i]='a'+y;
		}
	}
	return ret;
}

int gcd(int a,int b){
	if(b==0) return a;
	return gcd(b,a%b);
}

int main(){
	int n;
	//cin>>n;
	string tt;
	getline(cin,tt);
	n = atoi(tt.c_str());
	cout<<n<<" "<<tt<<endl;
	//cin.ignore();
	string str[2]={"that","this"};
	rep(i,0,n){
		string s;
		bool f=0;
		getline(cin,s);
		o(s);
		rep(a,0,26){
			if(gcd(a,26)!=1) continue;
			rep(b,0,26){
				string t;
				t=change(s,a,b);
				//o(t);
				rep(j,0,2){
					if(t.find(str[j]) != string::npos){
						o(t); f=1; break;
					}
				}
				if(f) break;
			}
			if(f) break;
		}

	}
}

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

#define rep(i,j) for(; i < j; i++)

char ch(int a, int b, int c) {
	return (a * (c - 'a') + b) % 26 + 'a';
}

int main() {
	int n, a, b, c;
	cin >> n;

	string str, res;
	while(n--) {
		getline(cin, str);

		a = b = 0;
		rep(a, 26) {
			rep(b, 26) {
				res = "";
				c = 0;
				rep(c, str.size()) {
					if (str[c] == ' ') {
						res += " ";
						continue;
					}

					res += ch(a, b, str[c]);
				}
				if (res.find("this") != string::npos || res.find("that") != string::npos) {
					cout << res << endl;
					a = 26;
					b = 26;
				}
			}
		}
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <ctype.h>
#include <sstream>
using namespace std;
 
bool in_word (string s1, string s2) {
    stringstream ss;
    ss << s1;
    while (ss >> s1) {
        if (s1 == s2) return true;
    }
    return false;
}
 
string affin (string str, int a, int b) {
    int tmp[26];
    for (int i = 0; i < 26; i++) tmp[i] = -1;
    for (int i = 0; i < str.size(); i++) {
        if (!(isalpha(str[i]))) continue;
        int s = str[i] - 'a';
        int g = (a * s + b) % 26;
        if (tmp[g] != -1 && tmp[g] != s) return "";
        else if (tmp[g] == -1) tmp[g] = s;
        str[i] = (char)(g + 'a');
    }
     
    return str;
}
 
int main ()
{
    int n;
    cin >> n;
    string str;
    getline(cin, str);
    while (n--) {
        getline(cin, str);
        for (int i = 0; i <= 26; i++) {
            for (int j = 0; j <= 26; j++) {
                string tmp = affin(str, i, j);
                if (tmp == "") continue;
                if (in_word(tmp, "this") || in_word(tmp, "that")) {
                    cout << tmp << endl;
                }
            }
        }
    }
     
    return 0;
}

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

using namespace std;


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;

	scanf("%d",&n);
	getchar();
	for(int i=0;i<n;i++){
		fgets(buf,300,stdin);
		length = 0;

		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;

					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){
							b = p;
							break;
						}
					}
					if(b != -1){
						if(judge(a,b) == true)break;
					}

					a = -1;
					b = s3;
					for(int p=0;p<26;p++){
						if((19*p+b)%26==s1){
							a = p;
							break;
						}
					}
					if(a != -1){
						if(judge(a,b) == true)break;
					}
				}
				length = 0;
			}else if(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;

					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){
							b = p;
							break;
						}
					}
					if(b != -1){
						if(judge(a,b) == true)break;
					}


					a = -1;
					b = s3;
					for(int p=0;p<26;p++){
						if((19*p+b)%26==s1){
							a = p;
							break;
						}
					}
					if(a != -1){
						if(judge(a,b) == true)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\n",buf);
	}

    return 0;
}

C++: #include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
#include<map>
#include<cmath>
#include<complex>
using namespace std;

typedef complex<double> P;

#define X real()
#define Y imag()
typedef int kz;

kz gcd(kz a,kz b) { if(b==0) return a; else gcd(b,a%b); }

int main(){
    int mod=1000000007;
    int n,len,x,y;
    char s[260];
    scanf("%d",&n);
    while (fgets(s,260,stdin)!=NULL) {
        len=strlen(s)-1;
        bool flg=0;
        for (int a=0;a<26;++a) {
            if (gcd(a,26)!=1) continue;
            for (int b=0;b<26;++b) {
                char chk[len];
                for (int c=0;c<len;++c) {
                    if (isalpha(s[c])) {
                        chk[c]=(((s[c]-'a')*a+b)%26)+'a';
                    }
                }
                for (int d=0;d<len;++d) {
                    if (!strncmp(&chk[d],"this",4) || !strncmp(&chk[d],"that",4)) {
                        x=a;
                        y=b;
                        flg=1;
                    }
                }
            }
        }
        char ans[len];
        for (int i=0;i<len;++i) {
            if (isalpha(s[i])) ans[i]=(((s[i]-'a')*x+y)%26+'a');
            else ans[i]=s[i];
        }
        if (flg) printf("%s\n",ans);
    }
    return 0;
}

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

string AffineCipher(string s, int a, int b){
	for (int i = 0; i < s.size(); ++i){
		if (s[i] >= 'a' && s[i] <= 'z')
			s[i] = (a*(s[i] - 'a') + b) % 26 + 'a';
	}
	return s;
}

string DeAffine(string s, int a, int b){
	int t;
	for (int i = 0; i < s.size(); ++i){
		if (s[i] >= 'a' && s[i] <= 'z'){
			t = (((s[i] - 'a') - b) * a);
			while(t<0)
				t+=26;
			s[i] = t % 26 + 'a';
		}
	}

	return s;

}



int main(){
	int n, b;
	int a[12] = { 1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25 };
	string s,t;
	string key1, key2;
	bool found;
	cin >> n;cin.ignore();

	for (int j = 0; j < n; ++j){
		
		getline(cin,s);
		
		cout << s << endl;
		
		for (int i = 0; i < 12;++i){

			for (b = 1; b <= 26; ++b){
				
				t = DeAffine(s,a[11-i],b);
				
				if (t.find("this") != -1 || t.find("that") != -1){
					cout << t << endl;
				}
			}
		}
	}
}