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 <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)

static const double PI=6*asin(0.5);
typedef complex<double> P;
typedef long long ll;

int n;
vector<string> s;
vector<string> st;
string t;
vector<int> a;
vector<int> b;
int al,be;
int alpha=-1,beta=-1;

int afin(char s,int u,int t);

int gcd(int x,int y){
	if(y==0) return x;
	return gcd(y,x%y);
}
void atis(string st,int al,int be){
	if(afin(st[2],al,be)==0&&afin(st[3],al,be)==19){
		alpha=al;
		beta=be;
		//cout<<alpha<<" "<<beta<<endl;
	}
	if(afin(st[2],al,be)==8&&afin(st[3],al,be)==18){
		alpha=al;
		beta=be;
		//cout<<alpha<<" "<<beta<<endl;
	}
}

bool th(string st){
	int al,be;
	rep(i,a.size()){
		rep(j,b.size()){
			if(afin(st[0],a[i],b[j])==19&&afin(st[1],a[i],b[j])==7){
				al=a[i];
				be=b[j];
				atis(st,al,be);
				//cout<<al<<" "<<be<<endl;
			}
		}
	}
}
//abcdefghijklmnopqrstuvwxyz
//012345678901234567890123456
			


int afin(char s,int u,int t){
	int c=s-'a';
	//cout<<s<<" "<<c<<endl;
	return (u*c+t)%26;
}

int main(){
	cin>>n;
	//string thth="thth";
	//printf("%d %d\n",thth[0],thth[1]);
	rep(i,500){
		if(gcd(i+1,26)==1){
			a.push_back(i+1);
			//cout<<i+1<<endl;
		}
	}
	rep(i,26) b.push_back(i);
	rep(k,n){
		s.clear();
		st.clear();
		
		
		int i=0;
		char tmp[300]={0};
		string tm;
		string tt;
		char tmtm;
		gets(tmp);
		//cout<<1<<" "<<tmp<<endl;
		gets(tmp);
		//cout<<2<<" "<<tmp<<endl;
		//cout<<tmp<<endl;
		/*
		rep(i,300){
			printf("%c ",tmp[i]);
			if(tmp[i]==0) break;
		}
		cout<<endl;
		rep(i,300){
			printf("%d ",tmp[i]);
			if(tmp[i]==0) break;
		}
		cout<<endl;
		*/
		rep(i,300){
			//printf("%d\n",tmp[i]);
			if(!(tmp[i]>='a'&&tmp[i]<='z')&&tmp[i]!=' '){
				s.push_back(tm);
				//cout<<""<<endl;
				break;
			}
			else if(tmp[i]==' '){
				s.push_back(tm);
				//cout<<tm<<endl;
				tm.clear();
			}
			else{
				tt=tmp[i];
				tm+=tt;
			}
		}
		rep(i,s.size()){
			//cout<<s[i]<<endl;
		}
		
		
		//gets(tmp);
		//cout<<3<<" "<<tmp<<endl;
		
		//cout<<tmp;
		
		rep(i,s.size()){
			if(s[i].size()==4){
				st.push_back(s[i]);
				//cout<<s[i]<<endl;
			}
		}
		rep(i,st.size()){
			th(st[i]);
			//if(alpa>0) cout<<"alpa="<<alpa<<" beta="<<beta<<endl;
		}
		
		rep(i,s.size()){
			rep(j,s[i].size()){
				printf("%c",afin(s[i][j],alpha,beta)+'a');
			}
			
			if(i!=s.size()-1)	cout<<" ";
			else cout<<endl;
		}
		s.clear();
		//cout<<"hoge"<<endl;
	}
	return 0;
}

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

bool ok(int a,int b){
	int ta[26];
	fill(ta,ta+26,0);
	for(int i=0;i<26;i++){
		ta[(a*i+b)%26]++;
	}
	for(int i=0;i<26;i++)if(ta[i]>=2)return 0;
	return 1;
}
char ango(char n,int a,int b){
	int y=n-'0';
	int next=(y*a+b)%26;
	char tmp='a';
	for(int i=0;i<next;i++)tmp++;
	return tmp;
}
int main(){
	int ccc;
	cin>>ccc;
	cin.ignore();
	for(int cc=0;cc<ccc;cc++){
		string tn,n;
		getline(cin,n);
		for(int a=0;a<=26;a++){
			for(int b=0;b<=26;b++){
				tn=n;
				if(ok(a,b)){
					for(int i=0;i<(int)tn.size();i++){
						if(tn[i]!=' ')tn[i]=ango(tn[i],a,b);
					}
					bool f=0;
					for(int i=0;i<(int)tn.size()-3;i++){
						string tmp="aaaa";
						for(int j=0;j<4;j++)tmp[j]=tn[i+j];
						if(tmp=="this"||tmp=="that"){cout<<tn<<endl;goto next;}
					}
				}
			}
		}
		
		next:;
	}
	
	return 0;
}

C++: #include<iostream>
#include<string>
#include<cctype>
using namespace std;
#define NON string::npos
int main(){
  int n;
  (cin >> n).ignore();
  while(n--){
    string str;
    getline( cin, str);
    for(int i = 0 ; i < 26 ; i++ ){
      for(int j = 0 ; j < 26 ; j++ ){
        string ret = str;
        for(int k = 0 ; k < ret.size() ; k++ ){
          if(islower(ret[k])) ret[k] = ((ret[k] - 'a') * i + j) % 26 + 'a';
        }
        if(ret.find("that") != NON || ret.find("this") != NON){
          cout << ret << endl;
          i = j = 27;
        }
      }
    }
  }
}

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

char encode(char x,int a,int b){
	return ( ( a * (x-'a') + b) % 26 ) + 'a';
}

char decode(char x, int a, int b){
	int t = ( x - 'a') - b;
	while( (t%a) != 0 ) t += 26;
	return (t/a) % 26 + 'a';
}

string encode(string s, int a, int b){
	for(int i =0 ; i<(int)s.size() ; ++i )
		if( s[i] >= 'a' && s[i] <= 'z' )
			s[i] = encode( s[i] , a , b );
	return s;
}

string decode(string s, int a, int b){
	for(int i =0 ; i<(int)s.size() ; ++i )
		if( s[i] >= 'a' && s[i] <= 'z' )
			s[i] = decode( s[i] , a , b );
	return s;
}

int main(){
	int n=1;
	int a[12] = {1,3,5,7,9,11,15,17,19,21,23,25};
	
	string str, s;
	scanf("%d ", &n);
	
	for(int i=0 ; i<n ; ++i){
		bool flag = false;
		//getline( cin , str );
		char foo[257];
		gets( foo );
		str = foo;

		for(int i=0 ; i<12 ; ++i){
			for(int j=0 ; j<26 ; j++){
				s = decode( str , a[i] , j );
				if( s.find("this") != string::npos || s.find("that") != string::npos ){
					flag = true;
					break;
				}
			}
			if( flag ) break;
		}
		printf("%s\n" , s.c_str() );
	} 
}

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

using namespace std;

int gcd(int x,int y){
  if(y == 0)return x;
  return gcd(y,x%y);
}

int lcm(int x,int y){
  return (x*y)/gcd(x,y);
}

string affine(string s,int a,int b){
  string news;
  for(int i=0;i<s.length();i++){
    if(!('a'<= s[i] && s[i]<='z') ){
      news+=s[i];
      continue;
    }
    int y = s[i]-'a';
    news+= (char)((a*y+b)%26+'a');
  }
  
  return news;
}


int main(){

  int N;
  string s;
  cin >> N;
  cin.ignore();
  while(N-- > 0){
    getline(cin,s,'\n');
   
    bool fin = false;
    for(int a=1;a<=500;a++){
      if(gcd(a,26) == 1){
	for(int b=0;b<=500;b++){
	  string Ns = affine(s,a,b);	  
	  if(Ns.find("that") != string::npos || Ns.find("This") != string::npos){
	    cout << Ns << endl;
	    fin = true;
	    break;
	  }
	}

	}
	if(fin)break;
    }
    if(!fin)cout << s << endl;


  }
  return 0;
}

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

#define rep(a, b, i) for(int i = a; i < b; i++)

char ch(int a, int b, int c) {
	return (a * (c - 'a') + b) % 26 + 'a';
}

int main() {
	int n, a, b, c;
	cin >> n;
	cin.ignore();

	string str, res = "";
	for (; n > 0; n--) {
		getline(cin, str);

		rep(1, 30, a) {
			if (a == 2 || a == 13) continue;
			rep(1, 30, b) {
				res = str;
				c = 0;
				rep(0, str.size(), c) {
					if (res[c] == ' ') continue;

					res[c] = ch(a, b, res[c]);
				}
				if (res.find("this") != -1 || res.find("that") != -1) {
					cout << res << endl;
					a = 114514;
					b = 114514;
				}
			}
		}
	}
	return 0;
}