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 <bits/stdc++.h>
using namespace std;

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)):((m)-(n))),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)
#define loop for(;;)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;
typedef vector<int> vi;
typedef vector<string> vs;
typedef map<string,int> Dictionary;
const Real PI = acos(-1);

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

int dx[] = { -1, 0, 1, 0 };
int dy[] = {  0, -1, 0, 1 };

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

string affin(string s, int a, int b) {
  string r = "";
  rep (i, s.size()) {
    char c = s[i];
    if ('a' <= c && c <= 'z') {
      r += affin(c, a, b);
    }
    else {
      r += c;
    }
  }
  return r;
}

bool okay(string s) {
  if (s.find("this") != string::npos) return true;
  if (s.find("that") != string::npos) return true;
  return false;
}

int main() {

  int n; cin >> n;
  getchar();

  rep (_, n) {
    string s;
    getline(cin, s);

    rep (a, 26) {
      if (a % 2 == 0) continue;
      if (a % 13 == 0) continue;
      rep (b, 26) {
        string t = affin(s, a, b);
        if (okay(t)) {
          cout << t << endl;
          return 0;
        }
      }
    }
  }

  return 0;
}

C++: #include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<numeric>
using namespace std;
const int dx[]={1,0,-1,0};
const int dy[]={0,1,0,-1};
#define INF 1e+8
#define EPS 1e-7
#define PB push_back
#define fi first
#define se second
#define ll long long
#define MOD 26
#define reps(i,j,k) for(int i = (j); i < (k); i++)
#define rep(i,j) reps(i,0,j)
typedef pair<int,int> Pii;
typedef vector<int> vi;
int main(){
	int n;
	scanf("%d",&n);
	while(n--){
		getchar();
		string str;
		getline(cin,str);
		set < string > target;
		rep(i,str.size()-3){
			string sub(str,i,4);
			if(i == 0){
				if(str[4] == ' ' || str[4] == '\0'){
					if(str[0] != ' '&&str[1] != ' '&&str[2] != ' '&&str[3] != ' '){
						target.insert(sub);
					}
				}
			}
			else if(i == str.size()-4){
				if(str[str.size()-5] == ' '){
					if(str[i] != ' '&&str[i+1] != ' '&&str[i+2] != ' '&&str[i+3] != ' '){
						target.insert(sub);
					}
				}
			}
			else{
				if(str[i-1] == ' ' && str[i+4] == ' '){
					if(str[i] != ' '&&str[i+1] != ' '&&str[i+2] != ' '&&str[i+3] != ' '){
						target.insert(sub);
					}
				}
			}
		}
		string en = "abcdefghijklmnopqrstuvwxyz";
		string ans = "";
		int i = 0;
		int alpha;
		int beta;
		while(++i){
			if(i%2 == 0 || i%13 == 0)continue;
			rep(j,26){
				rep(k,2){
					string sub;
					if(k == 0){
						sub = "this";
					}
					if(k == 1){
						sub = "that";
					}
					rep(l,4){
						sub[l] = en[((i*(sub[l]-'a')+j) % MOD)];
					}
					if(target.count(sub)){
						alpha = i;
						beta = j;
						goto end;
					}
				}
			}
		}
		end:;
		map < char , char > memo;
		rep(i,26){
			memo[en[((alpha*i+beta) % MOD)]] = en[i];
		}
		rep(i,str.size()){
			if(str[i] == ' ')ans += " ";
			else ans += memo[str[i]];
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  for(int i=-1; i<n; i++) {
    string s;
    getline(cin,s);
    if(i==-1) continue;
    bool ck=false;
    for(int a=1; a<26; a++) {
      if(26%a!=0 || a==1) {
	for(int b=0; b<26; b++) {
	  char c[26];
	  for(int i=0; i<26; i++){
	    c[(i*a+b)%26]=i+'a';
	  }
	  string t=s;
	  for(int i=0; i<t.size(); i++){
	    if(t[i]!=' ') t[i]=c[t[i]-'a'];
	  }
	  if(t.find("that")!=-1 || t.find("this")!=-1) {
	    s=t;
	    ck=true;
	    break;
	  }
	}
      }
      if(ck) break;
    }
    
    cout << s << endl;
  }
  return 0;
}

C++: //Affine Cipher
#include<bits/stdc++.h>
using namespace std;

int a[11]={3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25};
vector<string> v;

void print(vector<string> p){
  for(int i=0; i<p.size(); i++){
    cout<<p[i];
    if(i==p.size()-1)cout<<endl;
    else cout<<' ';
  }
}

//n:aの番号
bool judge(int n, int b){
  vector<string> tmp;
  tmp=v;
  for(int i=0; i<tmp.size(); i++){
    for(int j=0; j<tmp[i].length(); j++){
      tmp[i][j]=((a[n]*((tmp[i][j]-'a'-b)>=0 ? tmp[i][j]-'a'-b : tmp[i][j]-'a'-b+26))%26)+'a';
    }
  }
  for(int i=0; i<tmp.size(); i++){
    if(tmp[i]=="that" || tmp[i]=="this"){
      print(tmp);
      return true;
    }
  }
  return false;
}

void solve(){
  for(int i=0; i<11; i++){
    for(int j=0; j<26; j++){
      if(judge(i, j))return;
    }
  }
}

int main(){
  int n;
  scanf("%d\n", &n);
  for(int i=0; i<n; i++){
    string s, t;
    getline(cin, s);
    stringstream ss(s);
    while(getline(ss, t, ' ')) v.push_back(t);
    solve();
  }
  return 0;
}

C++: #include <iostream>   
#include <map>   
#include <sstream>   
#include <string.h>   
using namespace std;   
  
map<int, char> AlphabetTable;   
map<int, int> table;   
  
char decode(char a){   
       
    int z = a - 'a';   
       
    for(int i = 0; i < 26; i++){   
        if(table[i] == z) return AlphabetTable[i];   
    }   
}   
  
void makeTable(int a, int b){   
    for(int i = 0; i < 26; i++){   
        table[i] = (a*i+b) % 26;   
    }   
}   
  
void makeAlphabetTable(){   
  
    char c = 'a';   
  
    for(int i = 0; i < 26; i++){   
        AlphabetTable[i] = c;   
        c++;   
    }   
}   
  
int main(){   
  
    string code, tmp;   
    int n;   
       
    getline (cin, code);   
    stringstream ssn(code);   
    ssn >> n;   
    makeAlphabetTable();   
    for(int i = 0; i < n; i++){   
        getline(cin, code );   
        tmp = code;   
        for(int b = 0; b < 26; b++){   
            for(int a = 1; a < 26; a+=2){   
                if(a%13 != 0){   
                    makeTable(a, b);   
                    code = tmp;   
                    for(int j = 0; j < code.length(); j++){   
                        if('a' <= code[j] && code[j] <= 'z'){   
                            code[j] = decode(code[j]);   
                        }   
                    }   
                    if(code.find("this") != -1 || code.find("that")!= -1){   
                        cout << code << endl;   
                        break;   
                    }   
                }   
            }   
        }   
    }   
       
    return 0;   
}