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<map>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>
#include<cmath>
using namespace std;
int inf = 1000000000;

char affine(char c, int a, int b){
  int x = c - 'a';
  int y = ( a * x + b ) % 26;
  char r = 'a' + y;
  return r;
}

int main(){

  int n;
  cin >> n;
  cin.ignore();
  bool f = true;
  for(int l=0; l<n; l++){
    string s;
    getline(cin, s);

    for(int i=1; i<50&&f; i++){
      if( i % 2 == 0 || i % 13 == 0 ) continue;
      for(int j=1; j<50&&f; j++){
        string t = s;
        for(int k=0; k<s.size(); k++){
          // if( 'a' <= s[k] && s[k] <= 'z' ) t += affine(s[k], i, j);
          // else t += s[k];
          if( 'a' <= s[k] && s[k] <= 'z' ) t[k]=(i*(t[k]-'a')+j)%26+'a';
          
        }
        if( t.find("that") != -1 || t.find("this") != -1 ){cout << t << endl; f = false; break;}
      }
    }

  }


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

	}
}

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

using namespace std;

int a,b;
vector<int> That;
vector<int> This;

vector<char> word;
vector<int> iword;

void init(){
	That.push_back(19);
	That.push_back(7);
	That.push_back(0);
	That.push_back(19);
	This.push_back(19);
	This.push_back(7);
	This.push_back(8);
	This.push_back(18);
}

bool ab(){
	for(int i=2; i<=26; i++){
		if(26%i==0){
			if(a%i==0)return false;
		}
	}
	return true;
}

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

int change(char c){
	if(c>='a'&&c<='z')return c-'a';
	return -1;
}
void getWord(string s,int *n){
	word.clear();
	for(; *n<s.size(); *n+=1){
		// cout<<"s:"<<s<<endl;
		// cout<<"j:"<<*n<<" "<<s.at(*n)<<endl;
		if(s.at(*n)==' '||s.at(*n)=='\0'){
			*n+=1;
			return;
		}
		//cout<<"j:"<<*n<<endl;
		word.push_back(s.at(*n));
	}
}

void getIword(){
	iword.clear();
	for(int i=0; i<word.size(); i++){
		iword.push_back(f(change(word.at(i))));
	}
}


char changeC(int i){
	return i+'a';
}

int main(){
	int n;
	string s;
	init();
	cin>>n;
	cin.ignore();
	//cout<<n<<endl;
	for(int i=0; i<n; i++){
		getline(cin,s);
		//cout<<s<<endl;
		bool flag=false;
		for(a=0; a<26; a++){
			for(b=0; b<26; b++){
				if(ab()){
					int j=0;
					while(j<s.size()){
						//<<j<<endl;
						getWord(s,&j);
						if(word.size()==4){
							getIword();
							if(iword==This||iword==That){
								// cout<<"a:"<<a<<" b:"<<b<<endl;
								// cout<<"iword:";
								// for(int i=0; i<iword.size(); i++){
								// 	cout<<changeC(iword.at(i));
								// }
								//cout<<endl;
								flag=true;
								break;
							}
						}
					}
				}
				if(flag)break;
			}
			if(flag)break;
		}
		for(int i=0; i<s.size(); i++){
			if(change(s.at(i))==-1)cout<<' ';
			else cout<<changeC(f(change(s.at(i))));
		}
		cout<<endl;
		//cout<<"a:"<<a<<" b:"<<b<<endl;
	}
	

}

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<<tmp;
					a=26;
					break;
				}
			}
		}
	}
	return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
	int n;
	int beta;
	string s,org(256,'@');
	cin >> n;
	cin.ignore();
	for(int i=0;i<n;++i){
		beta=0;
		getline(cin , s);
		while(org.find("this" ,0)==string::npos && org.find("that" , 0)==string::npos){
				for(int alpha=0;alpha<100000;++alpha){
						if(alpha){
							if(alpha%26==0|| 26%alpha==0) continue;
						}
						for(int k=0;k<26;++k){ 
							if((int)(s[0]-'a')==(int)((alpha*k+beta) % 26)){
								for(int l=0;l<s.size();++l){
									for(int m=0;m<26;++m){
										if(s[l]==' ') {org[l]=' ';  continue;}
										if((s[l]-'a')==((alpha*m+beta)%26)){
											org[l]=m+'a';
											break;
										}
									}
								}
							}
						}
				}
			beta++;
		}
		int index=org.find_first_of('@');
		org.erase(index);
		cout << org << endl;
	}
	return 0; 
}