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 <vector>
#include <fstream>
#include <string>
#include <algorithm>

using namespace std;

int main(){

	int n;
	cin>>n;
	string str;
	getline(cin,str);
	for(int i = 0; i < n; i++){
		getline(cin,str);
		bool f =false;
		for(int a=0; a < 26; a++){
			if(a%2!=0&&a%13!=0){
				for(int b=0; b < 26; b++){
					if(a==0&&b==10){
//						cout<<endl;
					}

					string nstr;
					// Ï·e[uðì¬
					char table[200];
					fill(table,table+200,0);

					for(int c = 'a'; c <= 'z'; c++){
						table[((a*(c-'a')+b)%26)+'a']=c;
					}
					
					// Ï·e[uð³É¡
					for(int i = 0; i < str.size(); i++){
						if(str[i]>='a'&&str[i]<='z'){
							nstr+=table[str[i]];
						}
						else
							nstr+=str[i];
					}

					// àµthatÜ½ÍthisÌ¶ªmFÅ«êÎI¹
					for(int i = 0; i + 3 < str.size(); i++){
						if(nstr.substr(i,4)=="this"||nstr.substr(i,4)=="that"){
							f=true;
							cout<<nstr<<endl;
							break;
						}
					}
					if(f)
						break;
				}
				if(f)
					break;
			}
		}
	}

	return 0;
}

C++: 
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
#endif

#define ITER(c)         __typeof__((c).begin())
#define FOREACH(it, c)  for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)        __typeof__((c).rbegin())
#define RFOREACH(it, c) for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)       REPEAT(i, 0, n)
#define REPEAT(i, k, n) for (int i = (k); i < (n); ++i)
#define REVREP(i, n)    for (int i = ((n)-1); i >= 0; --i)
#define FIND(c, n)      std::find((c).begin(), (c).end(), (n));
#define BSEARCH(c, n)   std::binary_search((c).begin(), (c).end(), (n))
#define LLPOW(p1,p2)    ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A)      (sizeof(A)/sizeof((A)[0]))
#define MIN(p1,p2)      (((p1)<(p2))?(p1):(p2))
#define MAX(p1,p2)      (((p1)>(p2))?(p1):(p2))
#define CIN_NO_SYNC     do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p)       fgets((p), sizeof(p), stdin)
#define CHOMP(p)        do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n') *_q = 0; } while(0)

typedef long long ll;
typedef unsigned long long ull;

#ifdef _DEBUG
#define pf printf
#define pr(n) do { cout << #n " = " << (n) << endl; } while(0)
#else
#define pf(...) /* */
#define pr(...) /* */
#endif

ll gcd(ll num1, ll num2){ return num2 == 0 ? num1: gcd(num2, num1 % num2); }

// F(r) = (ar + b) mod 26 
// r = F(r) - b + 26k) ≡ 0 (mod a)
char decode(const char ch, int n, int a, int b){
    if(!islower(ch)) return ch;
    int t = (ch - 'a') - b;
    while(t < 0 || t % a != 0) t += n;
    return 'a' + (t/a) % n;
}

int main(){
    string s;
    getline(cin, s);
    int n;
    sscanf(s.c_str(), "%d", &n);

    REP(i,n){
        getline(cin, s);
        REPEAT(j,1,26){
            if(gcd(26,j) != 1) continue;
            REP(k,26){
                if(gcd(j,k) != 1) continue;
                string t = s;
                int len = t.size();

                REP(l,len){
                    t[l] = decode(t[l], 26, j, k);
                }

                pf("%d:%d %s\n", j, k, t.c_str());
                char buf[260];
                sprintf(buf, " %s ", t.c_str());
                if(strstr(buf, " that ") != NULL || strstr(buf, " this ") != NULL){
                    cout << t << endl;
                    goto END;
                }
            }
        }
END:;
    }

    return 0;
}

C++: #include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
	int n;
	string ns;
	getline(cin, ns);
	n = atoi(ns.c_str());
	while (n--){
		string s;
		getline(cin, s);
		for (int i = 1; i < 26; i += 2){
			if (i == 13)
				continue;
			REP(j, 25){
				string s2 = s;
				REP(k, s.length()){
					if ('a' <= s2[k] && s2[k] <= 'z'){
						s2[k] = 'a' + ((s2[k]-'a') * i + j) % 26;
					}
				}
				if (s2.find("that") != string::npos || s2.find("this") != string::npos){
					s = s2;
					i = j = 26;
				}
			}
		}
		cout << s << endl;
	}
}

C++: #include<iostream>
#include<stdio.h>
#include<string.h>


#define MAX_STR 257
#define ALFA_NUM 26

using namespace std;

int gcd(int);

int main(){

	int n;
	char str[MAX_STR],fstr[MAX_STR];
	bool flag;
	
	cin>>n;
	
	
	while(n--){
		flag=true;
		//改行がバッファに残っているので捨てる
		fflush(stdin);
		memset(str,'\0',sizeof(str));		
		fgets(str,sizeof(str),stdin);
		
		
		for(int i=0;i<100;i++){
			if(gcd(i)==1){
				for(int j=0;j<27;j++){
				
					memset(fstr,'\0',sizeof(fstr));
					
					for(int k=0;str[k]!='\n';k++){
						
						if(str[k]!=' '){
							fstr[k]=((i*str[k]+j)%ALFA_NUM)+'a';
						}
						else if(str[k]==' '){
							fstr[k]=str[k];
						}					
					}
					
					if(strstr(fstr,"that")||strstr(fstr,"this")){
						printf("%s\n",fstr);
						goto Z;
					}
				}
			}
		}
		Z:;
	}
}

int gcd(int n){
	int temp,m;
	m=ALFA_NUM;
	if(n>m){
		temp=n;
		n=m;
		m=temp;
	}
	while(1){
		if(n==0){
			return m;
		}
		temp=n;
		n=m%n;
		m=temp;
	}
}