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 <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <memory.h>
#include <cassert>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;

int gcd(int a,int b) {
	return b == 0 ? a : gcd(b, a % b);
}

int main() {
	int n; cin >> n;
	getchar();
	while (n--) {
		string s; getline(cin, s);
		rep(a, 26) if(gcd(a, 26) == 1) rep(b, 26) {
			string t = s;
			rep(i, t.size()) if (isalpha(t[i])) t[i] = (a * (t[i] - 'a') + b) % 26 + 'a';
			if(t.find("that") != -1 || t.find("that") != -1) {
				cout << t << endl;
				goto next;
			}
		}
		next:;
	}
	
	return 0;
}

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

int code[26];

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

int affine(int m, int a, int b){
  return (m * a + b) % 26;
}

int main(void){
  int n;
  string p;
  cin >> n; cin.ignore();
  
  while(n--){
    getline(cin, p);
    bool finded = false;
    for(int a = 1; a < 26; a++){
      if(finded) break;
      if(gcd(a, 26) != 1) continue;

      for(int b = 1; b < 26; b++){
        for(int i = 0; i < 26; i++){
          code[affine(i, a, b)] = i;
        }

        for(int i = 0; i < p.size(); i++){
          if(p[i] != ' ') p[i] = (char)(code[p[i] - 'a'] + 'a');
        }

        if(p.find("this") + 1 || p.find("that") + 1){
          cout << p << endl;
          finded = true;
          break;
        }
      }
    }
  }
  return 0;
}

C++: #include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int a, b;

void check(int A[], char inp[]){
    int k;
    rep(i, 1000){
        rep(j, 1000){
            if((i * A[0] + j) % 26 == inp[0] - 'a'){
                for(k = 1; k < 4; k++){
                    if((i * A[k] + j) % 26 != inp[k] - 'a') break;
                }
            }
            if(k == 4){
                a = i;
                b = j;
                return;
            }
        }
    }
}

int main(){
    char str[512][512];
    char inp[512];
    int n,s;
    int This[4] = {19, 7, 8, 18}, That[4] = {19, 7, 0, 19};
    while(cin >> n){
        rep(i,n){
            a = b = -1;
            for(s = 0; cin >> inp; s++){
                strcpy(str[s], inp);
                if(strlen(inp) == 4 && a == -1){
                    check(This, inp);
                    if(a == -1)
                        check(That, inp);
                }
            }
            rep(j,s){
                rep(k, strlen(str[j])){
                    rep(l,26){
                        if((a * l + b) % 26 == str[j][k] - 'a'){
                            printf("%c",'a' + l);
                        }
                    }
                }
                cout << ' ';
            }
            cout << endl;
        }
    }
}

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

map<char,int> c_i;
map<int,char> i_c;
string str;

void init(){
  for(char ch = 'a' ; ch <= 'z' ; ch++){
    c_i[ch] = ch - 'a';
    i_c[ch-'a'] = ch;
  }
}

bool serch(string s){
  int a = s.find("that");
  int b = s.find("this");

  if(a != string::npos || b != string::npos) return true;
  return false;
}

char change(char ch,int a,int b){
  int num = c_i[ch];
  int nnum = (a*num+b) % 26;

  return i_c[nnum];
}

int main(){
  int n;
  init();

  cin >> n;
  cin.ignore();

  while(n--){
    getline(cin,str);

    for(int i = 0 ; i < 26 ; i++){
      for(int j = 0 ; j < 26 ; j++){
	string tmp = "";
	for(int k = 0 ; k < str.size() ; k++){
	  if(islower(str[k])){
	    tmp += change(str[k],i,j);
	  }
	  else tmp += str[k];
	}
	if(serch(tmp)){
	  cout << tmp << endl;
	  goto end;
	}
      }
    }
  end:;
  }

  return 0;
}