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<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,i;
    int This[4] = {19, 7, 8, 18}, That[4] = {19, 7, 0, 19};
    while(cin >> n){
        rep(i,n){
            a = b = -1;
            for(i = 0; cin >> inp; i++){
                strcpy(str[i], inp);
                if(strlen(inp) == 4 && a == -1){
                    check(This, inp);
                    if(a == -1)
                        check(That, inp);
                }
            }
            rep(j,i){
                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 <string>
using namespace std;

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++){
        string c = "";
        for(int i = 0; i < p.size(); i++){
          if(p[i] == ' ') c += " ";
          else c += (char)(affine(p[i] - 'a', a, b) + 'a');
        }
        if(c.find("this", 0) != string::npos || c.find("that", 0) != string::npos){
          cout << c << endl;
          break;
        }
      }
    }
  }
  return 0;
}

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

using namespace std;

int a[12]={1,3,5,7,9,11,15,17,19,21,23,25};

string affine(string x){
	string tmp=x;
	for(int i=0; i<12; i++){
		int A=0;
		
		while(a[i]*A%26!=1)A++;
		for(int b=0; b<26; b++){
			if(tmp.find("this")==-1&&tmp.find("that")==-1){
				for(int s=0; s<x.size(); s++){
					if(isalpha(x[s]))tmp[s]=((A*(x[s]-'a')+26-b)%26)+'a';
				}
			}
		else return tmp;
		}
	}
	return tmp;
}


int main(){
	int n;
	string str;
	cin>>n;
	cin.ignore();
	while(n--){
		getline(cin, str);
		cout<<affine(str)<<endl;	
	}
	return 0;
}

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

string ss, THIS("this"), THAT("that");
int a, b, n;

bool ifincluded(string key, string trg){
    int count = 0;
    string::iterator itkey = key.begin();
    for(string::iterator it = trg.begin(); it != trg.end(); it++){
        if( *it == *itkey ){
            itkey++;
            if( itkey == key.end() ){
                return 1;
            }
        }else{
            itkey = key.begin();
            if( *it == *key.begin() ){
                itkey++;
            }
        }

    }
    return false;
}

int main(){
    cin >> n;
    getline(cin, ss);
    while( n-- > 0 ){
        getline(cin, ss);
        string cs;
        bool ok = false;
        for(a = 1; !ok && a < 26; a++){
            if( 26%a == 0 ) continue;
            for(b = 0; !ok && b < 26; b++){
                cs = ss;
                for(string::iterator it = cs.begin(); it != cs.end(); it++){
                    if( isalpha( *it ) ){
                        *it = ( (*it-'a') * a + b) % 26 + 'a'; 
                    }
                }
                if( ifincluded( THIS, cs ) ||
                    ifincluded( THAT, cs ) ){
                    ok = 1;
                }
            }
        }
        cout << cs << endl;
    }
    return 0;
}

C++: #include <stddef.h>
#include <iostream>
#include <string>
using namespace std;
int gcd(int a, int b) {
  return (b == 0) ? a : gcd(b, a % b);
}
int main() {
  int n, i, j;
  size_t k;
  string line, a;
  getline(cin, line);
  n = stoi(line);
  while (n--) {
    getline(cin, line);
    a.resize(line.size());
    for (i = 0; i < 26; i++) {
      if (gcd(i, 26) != 1) continue;
      for (j = 0; j < 26; j++) {
        for (k = 0; k < line.size(); k++)
          if (line[k] == ' ') a[k] = ' ';
          else a[k] = (i * (line[k] - 'a') + j) % 26 + 'a';
        if (a.find("this") != string::npos || a.find("that") != string::npos) {
          cout << a << endl;
          goto NEXT;
        }
      }
    }
    NEXT:
    ;
  }
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

map<char, char> computeMap(int a, int b) {
	map<char, char> res;
	for (int x = 0; x < 26; x++) {
		int y = (a * x + b) % 26;
		res[y + 'a'] = x + 'a';
	}

	return res;
}

string decode(string str, map<char, char> m) {
	for (auto &c : str) {
		c = isalpha(c) ? m[c] : c;
	}
	return str;
}

string solve(string str) {
	for (int a = 0; a < 25; a++) {
		for (int b = 0; b < 25; b++) {
			if (__gcd(a, b) != 1) continue;
			map<char, char> m = computeMap(a, b);
			string decoded = decode(str, m);
			if (decoded.find("that") != string::npos || 
				decoded.find("this") != string::npos) {
				return decoded;
			}
		}
	}
	return "hoge";
}

int main(void) {
	int N;
	cin >> N;
	cin.get();

	for (int i = 0; i < N; i++) {
		string str;
		getline(cin, str);
		cout << solve(str) << endl;
	}

	return 0;
}