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>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//????????????????????????????????????
#define int long long
#define str string
const int inf = 999999999999999999;
struct P {
	int pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {
	int to, cost;
};
int gcm(int i, int j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
typedef long long ll;
typedef long double ld;
//---------------------------------------------------
//+++++++++++++++++++++++++++++++++++++++++++++++++++
//---------------------------------------------------
str s;
str solve(int i, int j) {
	str a = "";
	for (int z = 0; z < s.size(); z++) {
		if (s[z] == ' ') a += " ";
		else a += (char)((i*((int)s[z] - 'a') + j) % 26) + 'a';
	}
	for (int z = 0; z < a.size() - 4; z++) {
		str t = "";
		for (int r = 0; r < 4; r++)
			t += a[z + r];
		if (t == "that" || t == "this")
			return a;
	}
	return "shippaidesu";
}
signed main() {
	int n;
	cin >> n;
	getchar();
	for (int i = 0; i < n; i++) {
		getline(cin, s);
		for (int i = 0; i < 30; i++) {
			if (gcm(26, i) > 1&&i!=0)
				continue;
			for (int j = 0; j < 30; j++) {
				if (solve(i, j) != "shippaidesu") {
					cout << solve(i, j) << endl;
					goto stop;
				}
			}
		}
	stop:;
	}
	getchar(); getchar();
}

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

bool isPrimary(int num) {
    return(num % 2 != 0 && num % 13 != 0);
}
char calc(int a, int b, char chr) {
    int num = chr - 'a';
    char ret = 'a' + ((num * a + b) % 26);
    return(ret);
}

int main(void) {
    int num; string input;
    scanf("%d", &num); //cout << num << endl;
    for(int r = 0; r < num; r++) {
        getline(cin, input); //cout << input << endl;
        getline(cin, input);
        bool found = false;
        
        for(int a = 0; a <= 26 && !found; a++) {
            for(int b = 0; b <= 26 && !found; b++) {
                if(isPrimary(a)) { //aと26が互いに素であるならば
                    for(int r = 0; r < input.length(); r++) {
                        if(!isalpha(input[r])) continue;
                        //cout << "choice:" << r << endl;
                        input[r] = calc(a, b, input[r]);
                    }
                    if((input.find("this") != string::npos) || (input.find("that") != string::npos)) {
                        found = true; //cout << input << endl;
                    }
                }
                    //cout << "新しい文字列：" << input << endl;
            }
        }
        cout << input << endl;
    }
    return(0);
}

C++: #include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <algorithm>
using namespace std;

#define rep(i,n) for((i)=0;(i)<(int)n;(i)++)
#define foreach(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)

int n;
const int MAX_N = 100000;
string in;
vector<int> v;
bool sieve[MAX_N];

inline char F(int alpha, int beta, char gamma) {
  return 'a'+((alpha*(gamma-'a')+beta)%26);
}

int main() {
  int i, j, k, l;
  fill(sieve, sieve + MAX_N, true);
  for (i = 2; i < MAX_N; i+=2) sieve[i] = false;
  for (i = 3; i < MAX_N; i+=2) if (sieve[i]) {
    v.push_back(i);
    for (j = i+i; j < MAX_N; j+=i) {
      sieve[j] = false;
    }
  }
  
  cin >> n;
  cin.ignore();
  int vsz = v.size();
  rep(i,n) {
    getline(cin, in);
    int insz = in.size();
    rep(j,vsz) rep(k,26) {
      string cipher;
      rep(l,insz) {
        if (in[l] == ' ') {
          cipher += ' ';
          continue;
        }
        cipher += F(v[j], k, in[l]);
      }
      if (cipher.find("that") != -1 || cipher.find("this") != -1) {
        cout << cipher << endl;
        j = vsz;
        k = 26;
      }
    }
  }
  return 0;
}

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

int func(int a, int b, int c)
{
	return (a * c + b) % 26;
}

int main(void)
{
	int n;
	string a;
	getline(cin, a);
	
	n = atoi(a.c_str());
	for (int i = 0; i < n; i++){
		// cout << "*" << endl;
		string str;
		getline(cin, str);
		
		for (int a = 0; a < 100; a++){
			for (int b = 0; b < 100; b++){
				string tmp = str;
				for (int j = 0; j < str.size(); j++){
						if (tmp[j] == '.') continue;
						if (tmp[j] == ' ') continue;
						if (isdigit(tmp[j])) continue;
						tmp[j] = func(a, b, str[j] - 'a') + 'a';
				}
				
				if (tmp.find("that") != string::npos || tmp.find("this") != string::npos){
					cout << tmp << endl;
					goto a;
				}
			}
		}
	}
	
	a:;
	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);
		string en = "abcdefghijklmnopqrstuvwxyz";
		string ans = "";
		rep(i,10000){
			if(i%26 == 0)continue;
			rep(j,26){
				string sub;
				rep(k,str.size()){
					if(str[k] == ' ')sub += " ";
					else sub += en[((i*(str[k]-'a')+j) % MOD)];
				}
				rep(k,sub.size()-4){
					if(sub[k] == 't'&&sub[k+1] == 'h'&&sub[k+2] == 'i'&&sub[k+3] == 's'){
						ans = sub;
						goto end;
					}
					if(sub[k] == 't'&&sub[k+1] == 'h'&&sub[k+2] == 'a'&&sub[k+3] == 't'){
						ans = sub;
						goto end;
					}
				}
			}
		}
		end:;
		cout << ans << endl;
	}
	return 0;
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>

typedef long long ll;
using namespace std;

int F(int a, int b, int c){
	return (a*c+b) % 26;
}

int main(){
	int n;
	string str1;
	getline(cin,str1);

	n = atoi(str1.c_str());
	for(int i=0;i<n;i++){
		string str2;
		getline(cin,str2);

		for(int a=0;a<100;a++){
			for(int b=0;b<100;b++){
				string tmp = str2;
				for(int i=0;i<str2.size();i++){
					if(tmp[i]=='.') continue;
					if(tmp[i]==' ') continue;
					if(isdigit(tmp[i])) continue;
					tmp[i] = F(a,b,str2[i]-'a') + 'a';
				}

				if(tmp.find("that") != string::npos
					|| tmp.find("this") != string::npos){
						cout << tmp << endl;
						goto found;
				}
			}
		}
found:;
	}
}