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<algorithm>
using namespace std;
bool isalphad(char z){
	if(z>='a'&&z<='z')return true;
	else return false;
}
int main(){
	string s,c;
	int n;
	cin>>n;
	for(int u=0;u<n;u++){
		cin.ignore();
		getline(cin,s);
		int a=0;
		bool ok=false;
		while(true){
			int b=0;
			while(true){
				c=s;
				for(int i=0;i<s.size();i++){
					if(isalphad(c[i])){
						c[i]='a'+((c[i]-'a')*a+b)%26;
					}
				}
				for(int i=0;i<s.size()-3;i++){
					if(c[i]=='t'&&c[i+1]=='h'&&c[i+2]=='i'&&c[i+3]=='s')ok=true;
					if(c[i]=='t'&&c[i+1]=='h'&&c[i+2]=='a'&&c[i+3]=='t')ok=true;
				}
				if(ok)break;
				b++;
				if(b==26)break;
			}
			if(ok)break;
			a++;
		}
		cout<<c<<endl;
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL << 30)
#define LLINF (1LL << 60)
#define PI 3.14159265359
#define EPS 1e-12
#define int ll

signed main(void) {
  int n;
  string s;
  cin >> n;
  while(getline(cin, s)) {
    //cout << o << endl;
    for (int i = 1; i < 26; i += 2) {
      if (i == 13)
        continue;
      REP(j, 26) {
        string t = s;
        REP(k, t.size()) {
          if (t[k] == ' ')
            continue;
          t[k] = (char)('a' + (i * (t[k] - 'a') + j) % 26);
        }
        if (t.find("this") != string::npos || t.find("that") != string::npos) {
          cout << t << endl;
          break;
        }
      }
    }
  }

  return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
#include <cstdio>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define pb(a) push_back(a)
int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  int num;
  cin>>num;
  cin.ignore();
  rep(i,num){
    string s,ss;
    getline(cin,s);
    bool flag = true;
    ss = s;
    rep(i,26){
      rep(j,26){
	if(ss.find("that") == string::npos & ss.find("this") == string::npos){
	  rep(k,s.size()){
	    ss=((((s[i]-'a')*x)+y)%26)+'a';
	    
	  }
	    
	}else{
	  cout<<ss<<endl;
	  flag = false;
	  break;
	}
      }
      if(!flag){
	break;
      }
    }
  }
}

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

int main() {
	int n;
	cin >> n;
	for (int i = 0;i < n;i++) {
		string s;
		getchar();
		getline(cin, s);
		int a = s.size();

		for (int j = 0;j < 26;j++) {
			for (int k = 0;k < 26;k++) {
				string sa = s;
				for (int l = 0;l < a;l++) {
					if (sa[l] >= 'a'&&sa[l] <= 'z') {
						int b = sa[l] - 97;
						b =( b*j + k)%26;
						b += 97;
						sa[l] = b;
					}
				}
				size_t za = sa.find("that");
				size_t zb = sa.find("this");
				if (za != string::npos || zb != string::npos) {
					s = sa;
					goto finloop;
				}
			}
		}
	finloop:
		cout << s << endl;
	}
	return 0;
}

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

int isSo(int a, int b) {
  int temp;
  if(a > b) temp = b;
  else temp  = a;
  for(int i = 2; i <= temp; i++) {
    if(a % i == 0 && b % i == 0) return 0;
  }
  return 1;
}
int mod26(int x) {
  return x % 26;
}

int main(void) {
  string str, out;
  int n;
  int flag;
  cin >> n;
  getchar();
  for(int i = 0; i < n; i++) {
    getline(cin, str);
    out = str;
    flag = 0;
    for(int a = 1; a <= 26; a++) {
      if(!isSo(a, 26)) continue;
      for(int b = 1; b <= 26; b++) {
	for(int j = 0; j < (int)str.length(); j++) {
	  if(str[j] == ' ') out[j] = str[j];
	  else out[j] = (char)(mod26(a*((int)str[j]-(int)'a')+b)+(int)'a');
	}
	for(int j = 0; j < out.length()-3; j++) {
	  string temp;
	  temp = out.substr(j,4);
	  if(temp == "that" || temp == "this") {
	    flag = 1;
	    break;
	  }
	}
	if(flag) break;
      }
      if(flag) break;
    }
    cout << out << endl;
  }
  return 0;
}

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

int GCD(int a, int b){
	return (b == 0) ? a:GCD(b, a%b);
}

char affine(int a, int b, char ch){
	int y = (int)(ch - 'a');
	return (char)((a*y+b)%26) + 'a';
}

int main(){
	bool ok;
	string str;
	getline(cin, str);
	while (getline(cin, str)) {
		ok = false;
		for (int a = 1; a < 26 && !ok; a++) {
			if(GCD(a, 26) != 1){
				continue;
			}
			for (int b = 0; b < 26 && !ok; b++) {
				for (int j = 0; j < str.size(); j++) {
					if('a' <= str[j] && str[j] <= 'z'){
						str[j] = affine(a, b, str[j]);
					}
				}
				if(str.find("that") != string::npos || str.find("this") != string::npos){
					cout << str << endl;
					ok = true;
				}
			}
		}
	}
	return 0;
}

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

using namespace std;

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

int main()
{
	int a[]={1,3,5,7,9,11,15,17,19,21,23,25,0};
	int n;	cin>>n;cin.ignore();
	string ciph,ciph_copy,sp=" ";

	while(getline(cin,ciph)){
		ciph=ciph_copy=sp+ciph+sp;
		bool f=false;
		for(int i=0;!f&&a[i];i++){
			for(int b=0;!f&&b<26;b++){
				for(int j=0;j<ciph.length();j++)
					ciph[j]=affine(a[i],b,ciph[j]);

				if(ciph.find(" that ")!=string::npos
				|| ciph.find(" this ")!=string::npos){
					f=true;
					break;
				}

				ciph=ciph_copy;
			}
		}
		cout<<ciph.substr(1,ciph.length()-2)<<endl;
	}

	return 0;
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

string S,coded;

int gcd(int a,int b){
	if (b==0) return a;
	return gcd(b,a%b);
}
							
int main(){
	int n;
	cin>>n;
	cin.ignore();
	REP(t,n){
		getline(cin,S);
		REP(a,26){
			if (gcd(a,26)!=1) continue;
			REP(b,26){
				coded.clear();
				REP(i,S.length()	){
					if (S[i]==' '){
						coded.push_back(' ');
					}else{
						int y=S[i]-'a';
						int c=a*y+b;
						c%=26;
						coded.push_back((char)(c+'a'));
					}
				}
				if (coded.find("that")!=string::npos || coded.find("this")!=string::npos){
					cout<<coded<<endl;
					a=b=26;
				}
			}
		}
	}
	return 0;
}