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 <iostream>
#include <cstring>
#include <string>
using namespace std;
int gcd(int s)
{
	for(int i=2;i<26;i++)
	{
		if(s%i==0&&26%i==0)return 1;
	}
	return 0;
}
int main()
{
	int n,a,b,c,len,i,j;
	cin >> n;
	while(getchar()!='\n');
	char str[257],tmp[257],henkan[26];
	for(i=0;i<n;i++)
	{
		fgets(str,sizeof(str),stdin);
		len = strlen(str);
		for(a=1;a<26;a++)
		{
			if(gcd(a))continue;
			for(b=1;b<26;b++)
			{
				memset(tmp,'\0',sizeof(tmp));
				for(c=0;c<26;c++)
				{
					henkan[(c*a+b)%26]=c;
				}
				for(j=0;j<=len;j++)
				{
					if(str[j]!= ' '&&str[j]!='\n')
					{
						tmp[j] = henkan[str[j]-'a']+'a';
					}
					else
					{
						tmp[j] = str[j];
					}
				}
				if(strstr(tmp,"this")||strstr(tmp,"that"))
				{
					cout << tmp << endl;
					a=26;
					break;
				}
			}
		}
	}
	return 0;
}

C++: #include<cstdio>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>

using namespace std;
typedef pair < int , int > Pii;
// 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;
		}*/
		vector < Pii > ok;
		int A = 500;
		int B = 500;
		for(int i = 2; i < A; i++ ){
			if(__gcd(i,26) != 1)continue;
			for(int j = i+1; j < B; j++){
				if(__gcd(i,j) != 1)continue;
				Pii p;
				p.first = i;
				p.second = j;
				ok.push_back(p);
			}
		}
		
		int a;
		int b;
		int index = 10000;
		int This[4];
		int That[4];
		for(int o = 0; o < ok.size(); o++){
			int i = ok[o].first;
			int j = ok[o].second;
			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 <iostream>

using namespace std;
int a[4];
char o[3]={'+','-','*'};
int gdb(int a,int b){
  int c;
  while(b){
    c=a%b;
    a=b;
    b=c;
  }
  return a;
}
int cl(int a,int b,int o){
  if(o==0) return a+b;
  else if(o==1) return a-b;
  else return a*b;
}
int solve(){
  for(int i=1;i<4;i++){
    if(gdb(i,4)!=1) continue;
    for(int j=0;j<4;j++){
      for(int k=0;k<3;k++){
	for(int l=0;l<3;l++){
	  for(int h=0;h<3;h++){
	    for(int m=0;m<5;m++){
	      int w,x,y,z;
	      char e,f,g;
	      w=a[j];x=a[(i+j)%4];y=a[(2*i+j)%4];z=a[(3*i+j)%4];
	      e=o[k];f=o[l];g=o[h];
	      if(m==0&&cl(cl(cl(w,x,k),y,l),z,h)==10){
		cout<<"(("<<w<<" "<<e<<" "<<x<<") "<<f<<" "<<y<<") "<<g<<" "<<z<<endl;
		return 0;
	      }
	      else if(m==1&&cl(cl(w,x,k),cl(y,z,h),l)==10){
		cout<<"("<<w<<" "<<e<<" "<<x<<") "<<f<<" ("<<y<<" "<<g<<" "<<z<<")"<<endl;
		return 0;
	      }
	      else if(m==2&&cl(cl(w,cl(x,y,l),k),z,h)==10){
		cout<<"(("<<w<<" "<<e<<" ("<<x<<" "<<f<<" "<<y<<")) "<<g<<" "<<z<<endl;
		return 0;
	      }
	      else if(m==3&&cl(w,cl(cl(x,y,l),z,h),k)==10){
		cout<<w<<" "<<e<<" (("<<x<<" "<<f<<" "<<y<<") "<<g<<" "<<z<<")"<<endl;
		return 0;
	      }
	      else if(m==4&&cl(w,cl(x,cl(y,z,h),l),k)==10){
		cout<<w<<" "<<e<<" ("<<x<<" "<<f<<" ("<<y<<" "<<g<<" "<<z<<"))"<<endl;
		return 0;
	      }
	    }
	  }
	}
      }
    }
  }
  cout<<"0"<<endl;
}
	  
int main(){
  while(cin>>a[0]>>a[1]>>a[2]>>a[3]){
    if(a[0]==0) break;
    int c=gdb(a[0],gdb(a[1],gdb(a[2],a[3])));
    if(c!=1&&c!=2&&c!=5){
      cout<<"0"<<endl;
      continue;
    }
    solve();
  }
  return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	int n,i,j,k;string s,t;cin>>n;
	while(n--){getline(cin,s);t=s;
		for(i=0;i<99;i++)for(j=0;j<99;j++){
			for(k=0;k<s.size();k++)t[k]=s[k]-32?97+(i*s[k]+j)%26:32;
			if(t.find("this")+1||t.find("that")+1)i=j=30;
		}cout<<t<<endl;
	}return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n;
	cin>>n;
	string tmp;
	getline(cin,tmp);
	while(n--){
		getline(cin,tmp);		
		rep(a,10000){
			bool h=false;
			rep(b,26){
				string s=tmp;
					rep(k,s.size())if(isalpha(s[k]))s[k]=(a*(s[k]-'a')+b)%26+'a';
				if(s.find("this")!=string::npos||s.find("that")!=string::npos){
					cout<<s<<endl;
					h=true;break;
				}
				if(h)break;
			}
			if(h)break;
		}
	}
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>
#include <random>
using namespace std;

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

char affinechar(char c, int a, int b) {
    if (islower(c)) {
        return 'a' + (a * (c - 'a') + b) % 26;
    }else {
        return c;
    }
}

void affineconv(string &s, int a, int b) {
    REP(i,s.size()) {
        s[i] =  affinechar(s[i], a, b);
    }
}

bool isEnglish(string s) {
    return s.find("that") != string::npos || s.find("this") != string::npos;
}

random_device rnd;

int rnda() {
    int a = rnd();
    a = abs(a) % 26;
    if (a % 2 == 0 || a % 13 == 0) {
        return rnda();
    }else {
        return a;
    }
}

int rndb() {
    return rnd() % 26;
}

int main() {
    string s;
    while(getline(cin, s)) {
        if (s.size() > 3) {
            while (!isEnglish(s)) {
                affineconv(s, rnda(), rndb());
                //cout << s << endl;
            }
            cout << s << endl;
        }
    }
    return 0;
}