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<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cctype>
#include<cstdlib>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
    int n;
    cin>>n;
    string str;
    getline(cin.str);
    while(n--){
        getline(cin,str);
        bool f=false;
        for(int a=1;!f;a++){
            if(a%2==0||a%13==0)continue;
            for(int b=0;!f&&b<26;b++){
                char m[26];
                for(int i=0;i<26;i++)m[(i*a+b)%26]=i+'a';
                string t=str;
                for(int i=0;i<t.size();i++){
                    if(islower(t[i]))t[i]=m[t[i]-'a'];
                }
                bool f_this=(t.find("this")!=string::npos);
                bool f_that=(t.find("that")!=string::npos);
                if(f_this||f_that){
                    str=t;
                    f=true;
                }
            }
        }
        cout<<str<<endl;
    }
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<map>
#include<queue>
#include<set>

using namespace std;
typedef pair<int,int> PII;
typedef long long ll;

int main(){
	int n;
	string line;
	cin>>n;
	getline(cin,line,'\n');
	for(;n>0;n--){
		getline(cin,line,'\n');
		int alpha[12] = {1,3,5,7,9,11,15,17,19,21,23,25};
		for(int b,i=0;i<12;i++){
			for(b = 0;b<26;b++){
				char chiper[26];
				for(int j=0;j<26;j++)
					chiper[j] = (alpha[i]*j+b)%26 + 97;
				string decode = line;
				for(int j=0;j<line.size();j++){
					if(line[j]>=97&&line[j]<=122)
						decode[j] = chiper[line[j]-97];
					else
						decode[j] = line[j];
				}
				if(decode.find("this") != -1 || decode.find("that") != -1){
					cout<<decode<<endl;
					break;
				}
			}
			if(b!=26)break;
		}
	}
  return 0;
}

C++: #include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<numeric>
using namespace std;
const int dx[]={1,0,-1,0};
const int dy[]={0,1,0,-1};
#define INF 1e+8
#define EPS 1e-7
#define PB push_back
#define fi first
#define se second
#define ll long long
#define MOD 26
#define reps(i,j,k) for(int i = (j); i < (k); i++)
#define rep(i,j) reps(i,0,j)
typedef pair<int,int> Pii;
typedef vector<int> vi;
int main(){
	int n;
	scanf("%d",&n);
	while(n--){
		getchar();
		string str;
		getline(cin,str);
		string en = "abcdefghijklmnopqrstuvwxyz";
		string ans = "";
		rep(i,1000){
			if(i%26 == 0)continue;
			rep(j,26){
				string sub;
				rep(k,str.size()){
					if(str[k] == ' ')sub += " ";
					else sub += en[((i*(str[k]-'a')+j) % MOD)];
				}
				rep(k,sub.size()-4){
					if(sub[k] == 't'&&sub[k+1] == 'h'&&sub[k+2] == 'i'&&sub[k+3] == 's'){
						ans = sub;
						goto end;
					}
					if(sub[k] == 't'&&sub[k+1] == 'h'&&sub[k+2] == 'a'&&sub[k+3] == 't'){
						ans = sub;
						goto end;
					}
				}
			}
		}
		end:;
		cout << ans << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
long i,j,k,n;
string s="that",t="this",ss;
cin>>n;getline(cin,ss);
for(k=0;k<n;k++){
getline(cin,ss);
for(i=1;i<26;i+=2){
if(i==13)continue;
for(j=0;j<26;j++){
t[0]=t[3]=s[0]=(i*19+j)%26+97;
t[1]=s[1]=(i*7+j)%26+97;
t[2]=(i*0+j)%26+97;
s[2]=(i*8+j)%26+97;
s[3]=(i*18+j)%26+97;
if(ss.find(t)!=string::npos)goto L1;
if(ss.find(s)!=string::npos)goto L1;
}
}
L1:
if(i==3)i=9;
else if(i==5)i=21;
else if(i==7)i=15;
else if(i==9)i=3;
else if(i==11)i=19;
else if(i==15)i=7;
else if(i==17)i=23;
else if(i==19)i=11;
else if(i==21)i=5;
else if(i==23)i=17;
for(k=0;k<ss.size();k++)
if(96<ss[k]&&ss[k]<123)ss[k]=(i*(ss[k]-97+26-j))%26+97;
cout<<ss<<endl;
}
return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;




int main(){


    int n;
    string s;
    string p;
    (cin >> n).ignore();
    cin.ignore();

    while(n--){
        
        getline(cin,s);
        
        for(int i = 0;i < 26;i++){
            
            for(int j = 0;j < 26;j++){

                string t = s;

                for(int k = 0;k < t.size();k++){

                    if(islower(t[k])){

                        t[k] = ((t[k]-'a')*i + j) % 26 + 'a';
                    }

                }
                if(t.find("this") != -1 || t.find("that") != -1){
                    cout << t << endl;
                    //cout << "puni" << endl;
                    i = j = 30;
                }

            }
        }
    }


    return 0;

}

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

void solve(string& s){
	for(int i = 1; i < 26; i+=2){
		if(i == 13)continue;
		for(int j = 0; j < 26; ++j){
			string ss = s;
			for(int k = 0; k < (int)s.size(); ++k){
				if('a' <= ss[k] && ss[k] <= 'z'){
					ss[k] = (i * (ss[k] - 'a') + j) % 26 + 'a';
				}
			}
			if(ss.find("this") != string::npos || ss.find("that") != string::npos){
				cout << ss << endl;
				return;
			}
		}
	}
}

int main()
{
	int n;
	string s;
	cin >> n; cin.ignore();
	for(int i = 0; i < n; ++i){
		getline(cin,s);
		solve(s);
	}
}

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

string convert(int a, int b, string str) {
    for (int i = 0; i < (int)str.length(); ++i) {
        if (str[i] != ' ')
            str[i] = char((a * (str[i] - 'a') + b) % 26 + 'a');
    }
    return str;
}


int main(void) {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        string str;
        getline(cin, str);
        getline(cin, str);
        for (int a = 0; a < 26; ++a) {
            for(int b = 0; b < 26; ++b) {
                string str2;
                stringstream ss;
                ss << convert(a, b, str);
                while (!ss.eof()) {
                    ss >> str2;
                    if (str2 == "this" || str2 == "that") {
                        cout << convert(a, b, str) << endl;
                        break;
                    }
                }
            }
        }
    }
    return 0;
}