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 <cstring>
using namespace std;

int main(){
	int gomi;
	cin >> gomi;
	cin.ignore();
	string str;
	while(getline(cin,str)){
		bool hata = false;
		int a = 0, b = 0;
		int p=-1,q;
		for(int i = 0; i < str.size()+1; i++){
			if(str[i] == ' ' || i == str.size()){
				q = i;
				if(q-p == 5){
					for(int j = 1; j < 26; j++){
						if(j%2==0 || j == 13){
							continue;
						}
						if((j*('t'-'a')-(str[i-4]-'a')-j*('h'-'a')+(str[i-3]-'a'))%26 == 0){
							if((j*('h'-'a')-(str[i-3]-'a')-j*('a'-'a')+(str[i-2]-'a'))%26 == 0 && (j*('a'-'a')-(str[i-2]-'a')-j*('t'-'a')+(str[i-1]-'a'))%26 == 0 ){
								cout << "ok" << endl;
								a = j;
								b = ((str[i-4]-'a')-j*('t'-'a'))%26;
								cout << a << " " << b << endl;
								if(b < 0){
									b += 26;
								}
								hata = true;
								break;
							}
						}
					}
				}
				p = q;
			}
			if(hata == true){
				break;
			}
		}
		for(int i = 0; i < str.size(); i++){
			if(str[i] != ' '){
				for(int j = 0; j < 26; j++){
					if(str[i]-'a' == (j*a+b)%26){
						str[i] = 'a'+j;
						break;
					}
				}
			}
		}
		cout << str << endl;
	}
}

C++: #include<cstdio>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>

using namespace std;
// F(y) = (a*y+b) mod 26
int main(){
	int n;
	scanf("%d",&n);
	bool f = false;
	while( n-- ){
		char hoge;
		hoge = getchar();
		string str;
		vector < string > vs;
		getline(cin,str);
		if(f){
			string tmp;
			tmp = hoge;
			tmp += str;
			swap(tmp,str); 
		}
		f = true;
		str+=" ";
		for(int i = 0; i < str.size()-5; i++){
			if(str[i] != ' ' && str[i+1] != ' ' && str[i+2] != ' ' && str[i+3] != ' ' && str[i+4] == ' '){
				string tmp = "";
				tmp += str[i];tmp+=str[i+1];tmp+=str[i+2];tmp+=str[i+3];
				vs.push_back(tmp);
			}
		}
		
		/*for(int i = 0; i < vs.size(); i++){
			cout << vs[i] << endl;
		}*/
		
		int a;
		int b;
		int index = 10000;
		int A = 100;
		int B = 100;
		int This[4];
		int That[4];
		for(int i = 1; i < A; i++ ){
			for(int j = 1; j < B; j++){
				This[0] = (i*('t'-'a')+j);
				This[1] = (i*('h'-'a')+j);
				This[2] = (i*('i'-'a')+j);
				This[3] = (i*('s'-'a')+j);
				
				That[0] = (i*('t'-'a')+j);
				That[1] = (i*('h'-'a')+j);
				That[2] = (i*('a'-'a')+j);
				That[3] = (i*('t'-'a')+j);
				
				for(int k = 0; k < vs.size(); k++){
					string x = "";
					string y = "";
					for(int q = 0; q < 4; q++)x+=(This[q]%26+'a');
					for(int q = 0; q < 4; q++)y+=(That[q]%26+'a');
					if(x == vs[k]){
						index = k;
						a = i;
						b = j;
						goto L;
					}
					if(y == vs[k]){
						a = i;
						b = j;
						index = k;
						goto L;
					}
				}
			}
		}
		L:;
		//printf("a = %d b = %d index = %d\n",a,b,index);
		string ans = "";
		for(int i = 0; i < str.size()-1; i++){
			int x = 0;
			if(str[i] == ' '){ans += " ";continue;}
			while((str[i]-'a'-b+x)%(a)!= 0)x+=26;
			ans += (str[i]-'a'-b+x)/a%26+'a';
		}
		
		cout << ans << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>

int extgcd(int a, int b, int& x, int& y){
	int d = a;
	if(b != 0){
		d = extgcd(b, a%b, y, x);
		y -= (a/b) * x;
	}else{
		x = 1; y = 0;
	}
	return d;
}

int mod_inverse(int a, int m){
	int x, y;
	extgcd(a, m, x, y);
	return (m + x % m) % m;
}

int main(){
	int n;
	std::cin >> n;
	std::cin.ignore();
	for(;n--;){
		std::string s;
		std::getline(std::cin, s);
		for(int a=1;a<26;a++){
			if(26 % a == 0)continue; //素ではない
			int b = 0;
			for(;b<26;b++){
				std::string new_s = s;
				int inverse_a = mod_inverse(a, 26);
				std::transform(new_s.begin(), new_s.end(), new_s.begin(),
											 [inverse_a, b](char c){
												 if(c < 'a' || c > 'z')return c;
												 int x = c - 'a';
												 int new_x = inverse_a * (x>b?x-b:x-b+26) % 26;
												 return static_cast<char>(new_x + 'a');
											 });
				if(new_s.find("this") != std::string::npos ||
					 new_s.find("that") != std::string::npos){
					std::cout << new_s << std::endl;
					break;
				}
			}
			if(b < 26){break;}
		}
	}
}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

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

bool check(vi a){
    int is[] = {19, 7, 8, 18};
    int at[] = {19, 7, 0, 19};
    rep(i,a.size()-3){
        bool c = true;
        rep(j,4)if(a[i+j] != is[j])c = false;
        if(c) return true;
    }
    rep(i,a.size()-3){
        bool c = true;
        rep(j,4)if(a[i+j] != at[j])c = false;
        if(c) return true;
    }
    return false;
}

signed main(void) {
    int num;
    cin >> num;
    string s;
    getline(cin,s);
    while(num--){
        getline(cin,s);
        int n = s.size();
        vi v(n,INF);
        rep(i,n)if(s[i] != ' '){
            v[i] = s[i] - 'a';
        }
        rep(a,26)if(gcd(a,26) == 1)rep(b,26){
            vi t = v;
            rep(i,n)if(t[i] < INF){
                t[i] = (a*t[i]+b) % 26;
            }
            if(check(t)){
                string ans = "";
                rep(i,n){
                    if(t[i] == INF)ans += " ";
                    else ans += t[i]+'a';
                }
                cout << ans << endl;
                a = b = INF;
            }
        }
    }
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <functional>
#include <sstream>
#include <complex>
#include <climits>
using namespace std;

#define REP(i,a,n) for(int i=(a);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define EPS 1e-8

string chipher(string s, int a, int b){
	rep(i,s.size())if( 'a'<=s[i] && s[i]<='z' ){
		s[i] = ((a*(s[i]-'a') + b)%26)+'a';
	}
	return s;
}
int gcd(int x, int y){
	return y ? gcd(y,x%y) : x;
}
int main(){
	int t;
	scanf("%d ",&t);
	while(t--){
		string in,ans; getline(cin,in);
		bool f = false;
		//cout << in << endl;
		for(int a=1; a<26; a++)if( gcd(a,26)==1 ){
			for(int b=1; b<=26; b++){
				string tmp = chipher(in,a,b);
				//printf("(%d,%d)::%s\n",a,b,tmp.c_str());
				if( tmp.find("that")!=string::npos || tmp.find("this")!=string::npos ){
					f = true; ans = tmp; break;
				}
			}
			if( f ) break;
		}
		cout << ans << endl;
	}
	return 0;
}