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

using namespace std;
// F(y) = (a*y+b) mod 26
int main(){
	int n;
	scanf("%d",&n);
	bool f = false;
	while( n-- ){
		char hoge;
		hoge = getchar();
		string str;
		vector < string > vs;
		getline(cin,str);
		if(f){
			string tmp;
			tmp = hoge;
			tmp += str;
			swap(tmp,str); 
		}
		f = true;
		str+=" ";
		for(int i = 0; i < str.size()-5; i++){
			if(str[i] != ' ' && str[i+1] != ' ' && str[i+2] != ' ' && str[i+3] != ' ' && str[i+4] == ' '){
				string tmp = "";
				tmp += str[i];tmp+=str[i+1];tmp+=str[i+2];tmp+=str[i+3];
				vs.push_back(tmp);
			}
		}
		
		/*for(int i = 0; i < vs.size(); i++){
			cout << vs[i] << endl;
		}*/
		
		int a;
		int b;
		int index = 10000;
		int A = 500;
		int B = 500;
		int This[4];
		int That[4];
		for(int i = 1; i < A; i++ ){
			for(int j = 1; j < B; j++){
				This[0] = (i*('t'-'a')+j);
				This[1] = (i*('h'-'a')+j);
				This[2] = (i*('i'-'a')+j);
				This[3] = (i*('s'-'a')+j);
				
				That[0] = (i*('t'-'a')+j);
				That[1] = (i*('h'-'a')+j);
				That[2] = (i*('a'-'a')+j);
				That[3] = (i*('t'-'a')+j);
				
				for(int k = 0; k < vs.size(); k++){
					string x = "";
					string y = "";
					for(int q = 0; q < 4; q++)x+=(This[q]%26+'a');
					for(int q = 0; q < 4; q++)y+=(That[q]%26+'a');
					if(x == vs[k]){
						index = k;
						a = i;
						b = j;
						goto L;
					}
					if(y == vs[k]){
						a = i;
						b = j;
						index = k;
						goto L;
					}
				}
			}
		}
		L:;
		//printf("a = %d b = %d index = %d\n",a,b,index);
		string ans = "";
		for(int i = 0; i < str.size()-1; i++){
			int x = 0;
			if(str[i] == ' '){ans += " ";continue;}
			while((str[i]-'a'-b+x)%(a)!= 0)x+=26;
			ans += (str[i]-'a'-b+x)/a%26+'a';
		}
		
		cout << ans << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>

#define SIZE 300005
#define MOD 1000000007LL
#define INF INT_MAX / 3
#define LLINF 1LL << 60
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define FORALL(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FOREACH(i,c) for(auto (i) : (c))
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef valarray<int> Array;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cout<<a[i];if(i==a.size()-1)cout<<endl;else cout<<" ";}}
int gcd(int a,int b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
int lcm(int a,int b){return a==0||b==0?0:a*b/gcd(a,b);}


vector<string> split(const string &str, char delim)
{
  istringstream iss(str); string tmp; vector<string> res;
  while(getline(iss, tmp, delim)) res.push_back(tmp);
  return res;
}

void solve(string s)
{
  int a = 0, b = 0;
  vector<string> words = split(s,0x20);
  for(auto t : words)
  {
    if(t.size() != 4) continue;
    else
    {
      bool f = false;
      FOR(v,1,25)
      {
        if(gcd(v,26)!=1) continue;
        FOR(w,0,25)
        {
          string tmp = t;
          REP(j,4) tmp[j] = 'a'+((v*(t[j]-'a')+w)%26);
          if(tmp == "this" || tmp == "that")
          {
            a = v; b = w; f = true;
            break;
          }
        }
        if(f) break;
      }
      if(f) break;
    }
  }
  REP(i,s.size()) if(s[i] != 0x20)s[i] = 'a'+((a*(s[i]-'a')+b)%26);
  printf("%s\n",s.c_str());
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n; cin.ignore();
  REP(i,n)
  {
    string s;
    getline(cin,s);
    solve(s);
  }
  return 0;
}

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:;
	}
}

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

int main(){
	int n;
	char str[257] = {}, str_c[257], len;
	cin >> n;
	//fflush(stdin);
	for (int m = 0; m < n; m++){
		int flag = false;
		fflush(stdin);
		gets(str);
		len = strlen(str);
		//printf("%d\n", len);
		for (int i = 0; i < 26; i++){
			/*if (i % 2 == 0 || i % 13 == 0) continue;*/
			for (int j = 0; j < 26; j++){
				for (int k = 0; k <= len; k++){
					if (isalpha(str[k])){
						str[k] -= 'a';
						str_c[k] = (str[k] * i + j) % 26 + 'a';
						str[k] += 'a';
					}
					else{
						str_c[k] = str[k];
					}
				}
				if (strstr(str_c, "this") || strstr(str_c, "that")){
					printf("%s\n", str_c);
					flag = true;
					break;
				}
			}
			if (flag) break;
		}
	}
	return 0;
}