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 <cstdio>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef vector<int> vi;
#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(c) int((c).size())

vi stovi(const string& s)
{
  vi v;
  tr (s, i) {
    v.pb(*i-'a');
  }
  return v;
}

string vitos(const vi& v)
{
  string s;
  tr (v, i) {
    s.pb('a'+*i);
  }
  return s;
}

void encode(int a, int b, const vi& from, vi& to)
{
  for (int i = 0; i < sz(to); i++) {
    if (0 <= from[i] && from[i] <= 25)
      to[i] = (a * from[i] + b) % 26;
    else
      to[i] = from[i];
  }
}

string code_break(const string& s)
{
  vi v = stovi(s);
  vi tmp = vi(sz(v));
  for (int a = 3; ; a++) {
    if ((a % 2) == 0 || (a % 13) == 0)
      continue;
    for (int b = 0; b < 25; b++) {
      encode(a, b, v, tmp);
      string s = vitos(tmp);
      if ((int)s.find("this ") >= 0
          || (int)s.find("that ") >= 0
          || (int)s.find(" this") >= 0
          || (int)s.find(" that") >= 0) {
        return s;
      }
    }
  }
}

int main(int argc, char **argv)
{
  int n;
  string s;
  cin >> n;
  getline(cin, s);
  while (n--) {
    getline(cin, s);
    cout << code_break(s) << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<string>
#include<stdio.h>
#include<ctype.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	string s;
	char r[257];
	for(int u=0;u<n;u++){
	    cin.ignore();
		getline(cin,s);
		int a=0,b=0;
		bool end=false;
		while(true){
			b=0;
			while(true){
		        for(int i=0;i<s.size();i++){
					if(isalpha(s[i])!=0)
			            r[i]=((s[i]-'a')*a+b)%26+'a';
					else
						r[i]=s[i];
				}
				for(int i=0;i<s.size()-3;i++){
					if(r[i]=='t'&&r[i+1]=='h'&&r[i+2]=='i'&&r[i+3]=='s'){
						end=true;
						break;
					}
					if(r[i]=='t'&&r[i+1]=='h'&&r[i+2]=='a'&&r[i+3]=='t'){
						end=true;
						break;
					}
				}
				if(end)break;
				if(b==100)break;
				b++;
			}
			if(end)break;
			a++;
		}
		for(int i=0;i<s.size();i++)
			cout<<r[i];
		cout<<endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
using namespace std;
int gcd(int s)
{
	for(int i=2;i<26;i++)
	{
		if(s%i==0&&26%i==0)return 1;
	}
	return 0;
}
int main()
{
	int n,a,b,c,len,i,j;
	cin >> n;
	while(getchar()!='\n');
	char str[257],tmp[257],henkan[26];
	for(i=0;i<n;i++)
	{
		fgets(str,sizeof(str),stdin);
		len = strlen(str);
		for(a=1;a<26;a++)
		{
			if(gcd(a))continue;
			for(b=1;b<26;b++)
			{
				memset(tmp,'\0',sizeof(tmp));
				for(c=0;c<26;c++)
				{
					henkan[(c*a+b)%26]=c;
				}
				for(j=0;j<=len;j++)
				{
					if(str[j]!= ' '&&str[j]!='\n'&&str[j]!='\0')
					{
						tmp[j] = henkan[str[j]-'a']+'a';
					}
					else
					{
						tmp[j] = str[j];
					}
				}
				if(strstr(tmp,"this")||strstr(tmp,"that"))
				{
					cout << tmp;
					a=26;
					break;
				}
			}
		}
	}
	return 0;
}

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

using namespace std;

string Affine(string S)
{
	vector<int> F(26);

	for (int i = 0; i < 26; i++) // alpha
	{
		for (int j = 0; j < 26; j++) // beta
		{
			for (int k = 0; k < 26; k++) // gamma
			{
				F[k] = (i * k + j) % 26;
			}
			
			string T = S;

			for (int k = 0; k < S.size(); k++)
			{
				if (islower(S[k]))
				{
					T[k] = F[S[k] - 97] + 97;
				}
				else
				{
					T[k] = S[k];
				}
			}

			if (T.find("this") != string::npos || T.find("that") != string::npos)
			{
				return T;
			}
		}
	}

	return "";
}

int main()
{
	int n; string S;

	cin >> n;

	for (int i = 0; i < n; i++)
	{
		S = "";

		getline(cin, S);

		cout << Affine(S) << endl;
	}
	
	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,10000){
			if(i%2 == 0 || i%13 == 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;
}