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 <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#define rep_to(a,i,n) for(i=a;i<n;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define rep_r(i,n) for(i=n-1;i>=0;i--)
#define debug_i(x) printf("x:%d\n",x)
#define debug_s(str) printf("str:%s\n",str)
#define debug_c(c) printf("c:%c\n",c) 

int main()
{
	int i,j,k,l;
	char str[257][257]={};
	char str2[257][257]={};
	char *p;
	int ans,count=1;
	int flag=0;

	fgets(str[0],sizeof(str[0]),stdin);
	str[0][strlen(str[0])-1]='\0';

	p=strtok(str[0]," ");
	strncpy(str[0],p,strlen(p));
	while(p!=NULL)
	{
		p=strtok(NULL," ");
		if(p!=NULL)
		{
			strncpy(str[count],p,strlen(p));
			count++;
		}
	}
	rep_to(1,i,1000)
	{
		rep_to(1,j,1000)
		{
			rep(k,count)
			{
				rep(l,strlen(str[k]))
				{
					str2[k][l]=(i*(str[k][l]-97)+j)%26+97;
				}
			}
			rep(k,count)
			{
				if(strstr(str2[k],"that")!=NULL)flag=1;
				else if(strstr(str2[k],"this")!=NULL)flag=1;
			}
			if(flag==1)break;
		}
		if(flag==1)break;
	}
	rep(i,count)
	{
		if(count-1!=i)printf("%s ",str2[i]);
		else printf("%s",str2[i]);
	}
	return 0;
}

C++: #include <string>
#include <iostream>
#include <map>
#include <cstdio>
#include <cstdlib>
 
using namespace std;
 
int AffineCipher(int a, int b, const char c){
	return (a*(c-'a')+b)%26 + 'a';
}

int main(){
    string s, s2;
	string kw[] = {"this", "that"};
	string alpha = "abcdefghijklmnopqrstuvwxyz";
	char decode[256];

	int n;
	getline(cin, s);
	n = atoi(s.c_str());
	const int sc = 1000;

    while(n--){
		getline(cin, s);
		string ckw[2] = {kw[0], kw[1]};
		bool found = false;
		int p;

		for(int a = 1; a < sc && !found; a+=2){
			for(int b = 0; b < 26; b++){
				for(int i = 0; i < kw[0].size();i++){
					ckw[0][i] = AffineCipher(a, b, kw[0][i]);
					ckw[1][i] = AffineCipher(a, b, kw[1][i]);
				}
				if(s.find(ckw[0]) != -1 || s.find(ckw[1]) != -1){
//					cout << a << " " << b << endl;
					for(int i = 0; i < 26; i++){
						decode[AffineCipher(a, b, alpha[i])] = alpha[i];
					}
					for(int i = 0; i < s.size(); i++){
						if(isalpha(s[i])){
							s[i] = decode[s[i]];
						}
					}
					cout << s << endl;
					found = true;
					break;
				}
			}
		}
	}
  
    return 0;
}

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

using namespace std;

int main(void){

	string sthat[27][27],sthis[27][27];
	for(int a=0;a<27;a++){
		for(int b=0;b<27;b++){
			sthat[a][b]=(char)((a*('t'-'a')+b)%26+'a');
			sthat[a][b]+=(char)((a*('h'-'a')+b)%26+'a');
			sthat[a][b]+=(char)((a*('a'-'a')+b)%26+'a');
			sthat[a][b]+=(char)((a*('t'-'a')+b)%26+'a');
			sthis[a][b]=(char)((a*('t'-'a')+b)%26+'a');
			sthis[a][b]+=(char)((a*('h'-'a')+b)%26+'a');
			sthis[a][b]+=(char)((a*('i'-'a')+b)%26+'a');
			sthis[a][b]+=(char)((a*('s'-'a')+b)%26+'a');
		}
	}

	int n;
	string in,inp;
	int mm;
	bool f;

	cin>>n;
	getchar();
	for(int i=0;i<n;i++){
		inp=("");
		while(1){
			in=getchar();
			if(in=="\n") break;
			else inp+=in;
		}
		f=true;
		for(int a=0;f&&a<27;a++){
			for(int b=0;f&&b<27;b++){
				if(inp.find(sthat[a][b])!=-1||inp.find(sthis[a][b])!=-1){
					for(int j=0;j<inp.length();j++){
						if(inp[j]!=' '){
							for(int k=26;;k+=26){
								if(((inp[j]-'a')+k-b)%a==0){
									mm=((inp[j]-'a')+k-b)/a;
									while(mm>=26) mm-=26;
									inp[j]=(char)(mm+'a');
									f=false;
									break;
								}
							}

						}
					}
				}
			}
		}
		cout<<inp<<endl;
	}

	return 0;
}

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


string rev(int a, int b, string x){
    string res = "";
    for(int i = 0;i < x.size();i++){
	if(x[i] < 'a' || x[i] > 'z')res += x[i];
	else{
	    int p = x[i] - 'a';
	    p += b;
	    p *= a;	    
	    p %= 26;
	    res += 'a' + p;
	}
    }
    return res;
}

int main(){
    int n;
    cin >> n;
    scanf("%*c");
    for(int i  = 0;i < n;i++){
	string input = "";
	char c;
	while(true){
	    c = getchar();
	    if(c == '\n' || c == EOF)break;
	    input += c;
	}
	string ans;
	for(int a = 1;a < 26;a++){
	    for(int b = 0;b < 26;b++){
		if(a % 2 == 0 || a % 13 == 0)continue;
		string o = rev(a, b, input);
		const char *orig = o.c_str();
		if(strstr(orig, "this") || strstr(orig, "that")){
		    ans = orig;
		}
	    }
	}
	cout << ans << endl;
    }
}

C++: #include <iostream>
#include <string>
#include <cctype>
#define conv(c) ((c) - 'a')
#define Rconv(c) ((c) + 'a')
using namespace std;

int main(){
  int n;
  cin >> n;
  while(n--){
    cin.ignore();
    string s,t,ans; getline(cin,s);

    for(int i=0;i<=25;i++){
      for(int j=0;j<=25;j++){
	t = s; ans = "";
	for(int k=0;k<t.size();k++){
	  if(isalpha(t[k])) ans += Rconv((conv(t[k])*i+j) % 26);
	  else ans += t[k];
	}
	if(ans.find("that") != string::npos || ans.find("this") != string::npos) goto exit;
      }
    }
  exit:;
    cout << ans << endl;
  }
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }


int f(int y, int a, int b)
{	return (a * y + b) % 26;	}

int main()
{
	int n;
	cin >> n;

	rep(i, n)
	{
		string str;
		cin.sync();
		getline(cin, str);
		int len = str.size();
		bool flag = true;

		for(int a = 0; a < 26; a++)
		{
			if(a % 2 != 0 && a % 13 != 0)
			{
				rep(b, 25)
				{
					// Ï·Îe[u
					int v[26];
					rep(y, 26)
						v[f(y, a, b)] = y;
					

					// Ï·
					string con = str;
					rep(in, len)
						if('a' <= con[in] && con[in] <= 'z')
							con[in] = v[con[in] - 'a'] + 'a';

					// Î`FbN
					rep(in, len - 3)
					{
						if(con.substr(in, 4) == "that" || con.substr(in, 4) == "this")
						{
							cout << con << endl;
							flag = false;
							goto ng;
						}
					}
				}
			}
		}
		if(flag) cout << str << endl;
ng:
		;
	}
	return 0;
}