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>

using namespace std;

int main(){
	int n;
	cin >> n;
	string s;
	getline(cin, s);
	while(n--){
		getline(cin, s);
		bool accept = false;
		for(int a = 1; !accept; ++a){
			if(a % 2 == 0 || a % 13 == 0){ continue; }
			for(int b = 0; !accept && b < 26; ++b){
				char map[26];
				for(int i = 0; i < 26; ++i){
					map[(i * a + b) % 26] = i + 'a';
				}
				string t = s;
				for(int i = 0; i < t.size(); ++i){
					if(islower(t[i])){ t[i] = map[t[i] - 'a']; }
				}
				bool found_this = (t.find("this") != string::npos);
				bool found_that = (t.find("that") != string::npos);
				if(found_this || found_that){
					s = t;
					accept = true;
				}
			}
		}
		cout << s << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

map<char, char> computeMap(int a, int b) {
	map<char, char> res;
	for (int x = 0; x < 26; x++) {
		int y = (a * x + b) % 26;
		res[y + 'a'] = x + 'a';
	}

	return res;
}

string decode(string str, map<char, char> m) {
	for (auto &c : str) {
		c = isalpha(c) ? m[c] : c;
	}
	return str;
}

string solve(string str) {
	for (int a = 0; a < 25; a++) {
		for (int b = 0; b < 25; b++) {
			map<char, char> m = computeMap(a, b);
			string decoded = decode(str, m);
			if (decoded.find("that") != string::npos || 
				decoded.find("this") != string::npos) {
				return decoded;
			}
		}
	}
	return "hoge";
}

int main(void) {
	int N;
	cin >> N;
	cin.get();

	for (int i = 0; i < N; i++) {
		string str;
		getline(cin, str);
		cout << solve(str) << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <math.h>

#define PREP(i, m, n) for(int i = m; i < n; i++)
#define MREP(i, m, n) for(int i = m - 1; i >= n; i--)

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define X first
#define Y second
#define MP make_pair
#define PB push_back

using namespace std;

map<int, char> number;

bool stringSearch(string input, string *after){
	for(int i = 0; i < 2; i++){
		if(input.find(after[i], 0) != string::npos){
			return true;
		}
	}
	return false;
}

void convert(string *after, string *key, int a, int b){
	for(int i = 0; i < 2; i++){
		for(int j = 0; j < key[i].size(); j++){
			after[i].push_back(number[(a * key[i][j] + b) % 26]);
		}
	}
}

void listConvert(map<char, char> &afterlist, int a, int b){
	for(int i = 0; i < 26; i++){
		afterlist[number[i]] = number[(a * number[i] + b) % 26];
	}
}

bool allSearch(string input, string *key){
	for(int a = 0; a < 26; a++){
		for(int b = 0; b < 26; b++){

			string after[2];
			map<char, char> afterlist;
			convert(after, key, a, b);
			listConvert(afterlist, a, b);

			if(stringSearch(input, after)){
				//文字があったら
				string answer;
				for(int i = 0; i < input.size(); i++){
					if(input[i] != ' '){
						for(map<char, char>::iterator it = afterlist.begin(); it != afterlist.end(); it++){
							if(it->second == input[i]){
								answer.push_back(it->first);
								break;
							}
						}
					}
					else answer.push_back(' ');
				}
				cout << answer << endl;
				return true;
			}

		}
	}
	return false;
}

int main(){
	string key[] = {"this", "that"};
	number[0] = 'a';
	number[1] = 'b';
	number[2] = 'c';
	number[3] = 'd';
	number[4] = 'e';
	number[5] = 'f';
	number[6] = 'g';
	number[7] = 'h';
	number[8] = 'i';
	number[9] = 'j';
	number[10] = 'k';
	number[11] = 'l';
	number[12] = 'm';
	number[13] = 'n';
	number[14] = 'o';
	number[15] = 'p';
	number[16] = 'q';
	number[17] = 'r';
	number[18] = 's';
	number[19] = 't';
	number[20] = 'u';
	number[21] = 'v';
	number[22] = 'w';
	number[23] = 'x';
	number[24] = 'y';
	number[25] = 'z';
	
	int n = 0;
	cin >> n;
	cin.ignore();
	while(n--){
		string input;
		getline(cin, input);
		allSearch(input, key);
	}

	return 0;
}

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

using namespace std;
typedef pair < int , int > Pii;
// 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;
		}*/
		vector < Pii > ok;
		int A = 1000;
		int B = 1000;
		for(int i = 2; i < A; i++ ){
			if(__gcd(i,26) != 1)continue;
			for(int j = i+1; j < B; j++){
				if(__gcd(i,j) != 1)continue;
				Pii p;
				p.first = i;
				p.second = j;
				ok.push_back(p);
			}
		}
		
		int a;
		int b;
		int index = 10000;
		int This[4];
		int That[4];
		for(int o = 0; o < ok.size(); o++){
			int i = ok[o].first;
			int j = ok[o].second;
			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;
}