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<string>
#include<map>
using namespace std;

int main(){

	int n, cnt_alph, cnt_word, valid, b;
	string str, word[51];
	map<int, char> mp;

	for(int i=0; i<26; i++){
		mp.insert(make_pair(i, 'a'+i));
	}

	cin >> n;
	getline(cin, str);

	for(int i=0; i<n; i++){
		cnt_alph = 0;
		cnt_word = 0;
		valid = 0;
	
		getline(cin, str);

		for(int j=0; j<str.length(); j++){
			if(str[j] != ' '){
				word[cnt_word] += str[j];
				cnt_alph++;
			}
			else {
				if(cnt_alph == 4)	cnt_word++;
				else word[cnt_word] = "";
				cnt_alph = 0;
			}
			if(j == str.length() - 1){
				if(cnt_alph == 4)	cnt_word++;
			}
		}
		for(int a=0; valid == 0; a++){
				for(int j=0; j<cnt_word; j++){
					if('t'-'a' > a*(word[j][1]-'a')){
						b = 't'-'a' - a*(word[j][1]-'a');
					}
					else{
						b = a*(word[j][1]-'a') - ('t'-'a');
					}
						if(mp[(a*(word[j][1]-'a')+b)%26] == 'h'){
							if((mp[(a*(word[j][2]-'a')+b)%26] == 'a' && word[j][0] == word[j][3]) || (mp[(a*(word[j][2]-'a')+b)%26] == 'i' && mp[(a*(word[j][3]-'a')+b)%26] == 's')){
								for(int k=0; k<str.length(); k++){
									if(str[k] != ' '){
										str[k] = mp[(a*(str[k]-'a')+b)%26];
									}
									cout << str[k];
								}
								cout << endl;
								valid = 1;
							}
						}
				}
		}
	}

	return 0;

}

C++: #include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
	int n,ar[] = {1,3,5,7,9,11,15,17,19,21,23,25};
	cin >>n;
	for(int i=0; i<n; i++){
		char word[300] = {0};
		int f = 0;
		for(int j=0;;j++){
			if(scanf("%c",&word[j]) == EOF){word[j] = 0;break;}
			if(word[j] == '\n'){break;}
		}
		for(int i=0; i<12; i++){
			for(int j=0; j<26; j++){
				for(int k=0; k<(int)strlen(word); k++){
					if(word[k]>='a' && word[k]<='z'){word[k] = (ar[i]*(word[k]-'a')+j)%26+'a';}
				}
				if(strstr(word," this ") != NULL){cout<<word;f = 1;break;}
				else if(strstr(word,"this ") != NULL){cout<<word;f = 1;break;}
				else if(strstr(word," this\n") != NULL){cout<<word;f = 1;break;}
				else if(strstr(word,"this\n") != NULL){cout<<word;f = 1;break;}
				else if(strstr(word," that ") != NULL){cout<<word;f = 1;break;}
				else if(strstr(word,"that ") != NULL){cout<<word;f = 1;break;}
				else if(strstr(word," that\n") != NULL){cout<<word;f = 1;break;}
				else if(strstr(word,"that\n") != NULL){cout<<word;f = 1;break;}
			}
			if(f == 1){break;}
		}
		if(f == 1){break;}
	}
	return 0;
}

C++: #include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



string tostr(char s[], int a, int n) {
    string res = "";
    for (int i = a; i < a+n; ++i) {
        if (s[i] != 0) res += s[i];
    }
    return res;
}




int n;

string solve(string str) {
	for (int i = 1; i < 26; ++i) {
		if (i % 2 == 0) continue;
		if (i % 13 == 0) continue;
		for (int j = 0; j < 26; ++j) {
			string next = "";
			for (int k = 0; k < str.size(); ++k) {
				if (str[k] == ' ') next += " ";
				else {
					int is = str[k] - 'a';
					int in = (is * i + j) % 26;
					char cn = 'a' + in;
					next += cn;
				}
			}

			bool con = false;
			for (int k = 0; k < next.size()-3; ++k) {
				string sub = next.substr(k, 4);
				if (sub == "this" || sub == "that") {
					con = true;
					break;
				}
			}
			if (con) {
				return next;
			}
		}
	}
	return str;
}



int main() {
	cin >> n; cin.ignore();
	string str;
	for (int i = 0; i < n; ++i) {
		getline(cin, str);
		//str = "y eazqyp pnop pngtg ye obmpngt xmybp mr lygw";
        cout << solve(str) << endl;
    }
    
    return 0;
}

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;
		}

	}
}