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 <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

string affine(string s, int alpha, int beta){
    int n = s.size();
    for(int i=0; i<n; ++i){
        if('a' <= s[i] && s[i] <= 'z')
            s[i] = ((alpha * (s[i]-'a') + beta) % 26) + 'a';
    }
    return s;
}

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

    while(--n >= 0){
        string s;
        getline(cin, s);

        for(int a=1; a<26; ++a){
            for(int b=0; b<26; ++b){
                string s1 = affine("that", a, b);
                string s2 = affine("this", a, b);
                if(s.find(s1) != string::npos || s.find(s2) != string::npos){
                    string to(26, ' ');
                    for(int i=0; i<26; ++i)
                        to[i] = i + 'a';
                    to = affine(to, a, b);
                    string from(26, ' ');
                    for(int i=0; i<26; ++i)
                        from[to[i]-'a'] = i + 'a';


                    for(unsigned i=0; i<s.size(); ++i){
                        if('a' <= s[i] && s[i] <= 'z')
                            s[i] = from[s[i]-'a'];
                    }
                    cout << s << endl;
                }
            }
        }
    }
}

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

using namespace std;

int a,b;
map<char, char> M;

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


void make(){
  M.clear();
  for(char c = 'a'; c <= 'z'; c++)
    M[Affine(c)] = c;
}


bool check(string in){
  string now = "";
  for(int i = 0; i < in.length(); i++){
    if(in[i] == ' '){
      //   cout << "now = " << now << endl;
      if(now == "this" || now == "that") return true;
      now = "";
    }
    else now += in[i];
  }
  return false;
}

string solve(string s){
 
  for(int i = 0; i < s.length(); i++)
    if(s[i] != ' ') s[i] = M[s[i]];

  if(check(s)) return s;
  return "-1";

}

void print(){
  for(char c = 'a'; c <= 'z'; c++)
    cout << M[c] << " ";

  cout << endl;

}

int GCD(int x,int y){
  if(y==0) return x;
  return GCD(y,x%y);
}
int main(){
  
  // print();
  // return 0;
  int n;
  cin >> n;
  cin.ignore();
  while(n--){
    string s;
    bool flg = false;
    getline(cin,s);
    for(int i = 0; i < 100; i++){
      for(int j = 0; j < 100; j++){
	a = i;
	b = j;
	if(GCD(a,26) != 1) continue;
	
	make();
	string ans;
	
	if((ans = solve(s)) != "-1"){
	  flg = true;
	  cout << ans << endl;
	  break;
	}
      }
      if(flg) break;
    }
    
  }
  return 0;
}

C++: #include <string>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <utility>
#include <algorithm>
#include <numeric>
#include <iostream>

using namespace std;
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

void solve(){
	string ori;
	getline(cin,ori);
	char dic[26];
	for (int b = 0; b < 26; b++){
		for (int a = 1; a < 26; a++){
			if(gcd(a,26) != 1) continue;
			string s(ori);
			for (int i = 0; i < 26; i++){
				dic[i] = (a * i + b) % 26;
			}
			for (int i = 0; i < s.length(); i++){
				if(s[i] >= 'a' && s[i] <= 'z')
					s[i] = (dic[s[i] - 'a']) + 'a';
			}
			if(s.find("that") != string::npos || s.find("this") != string::npos){
				cout << s;
				return;
			}
		}
	}
}

int main()
{
	int t; cin>>t;
	string buf; getline(cin,buf);
	while(t--){
		solve();
	}
}

C++: #include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <complex>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    //cout << fixed << setprecision(3);

    int n;
    cin >> n;
    
    while (n--)
    {string s = "", t = "";
        while(s=="")std::getline(std::cin, s);
        t = s;
        bool found = false;
        for (int i = 3; i < 26; ++i)
        {
            s = t;
            if (i % 26 == 0 || 26 % i == 0)
                continue;

            for (int j = 1; j <= 100; ++j)
            {
                if (i % j == 0 || j % i == 0 || 26 % j == 0 || j % 26 == 0)
                    continue;

                for (int k = 0; k < (int)s.size(); ++k)
                {
                    if (s[k] >= 'a' && s[k] <= 'z')
                    {
                        s[k] = (char)('a' + (i * (s[k] - 'a') + j) % 26);
                    }
                }
                if (s.find("that") != string::npos || s.find("this") != string::npos)
                {
                    cout << s << endl;
                    found = true;
                    break;
                }
            }
            if (found)
                break;
        }
    }
    return 0;
}