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<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
char c[257];
char d[257];
bool use[26];
int main(){
	int a;
	scanf("%d ",&a);
	while(a--){
		cin.getline(c,257);
		int t=strlen(c);
		for(int i=0;i<26;i++){
			for(int j=0;j<26;j++){
				bool ok=false;
				for(int k=0;k<26;k++)use[k]=false;
				for(int k=0;k<26;k++){
					if(use[(i*k+j)%26])goto dame;
					else use[(i*k+j)%26]=true;
				}
				for(int k=0;k<t;k++){
					if(c[k]<='z'&&c[k]>='a'){
						d[k]=(i*(c[k]-'a')+j)%26+'a';
					}else{
						d[k]=c[k];
					}
				}
				for(int k=0;k<t-3;k++){
					if(d[k]=='t'&&d[k+1]=='h'){
						if(d[k+2]=='a'&&d[k+3]=='t')ok=true;
						if(d[k+2]=='i'&&d[k+3]=='s')ok=true;
					}
				}
				if(ok){
					printf("%s\n",d);
					goto owari;
				}
				dame:;
			}
		}
		owari:;
	}
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define MAX_N 5001
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<string, ll> PS;
typedef vector<ll> V;

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

int n;
string s, ans;

int gcd(int a, int b){
	if (b == 0)return false;

	if (b == 1)return true;

	return gcd(b, a%b);
}

int main(){
	cin >> n;
	cin.ignore();
	REP(i, n){
		getline(cin, s);
		bool f = 0;
		for (int j = 1; j < 26; j++){
			if (!gcd(26, j))continue;
			for (int k = 0; k < 26; k++){
				//cout << j << " " << k << endl;
				REP(l, s.size()){
					if (s[l]<'a' || s[l]>'z'){
						ans += s[l];
						continue;
					}
					ans += (j*(s[l] - 'a') + k) % 26 + 'a';
				}
				if (ans.find("this") != -1
					|| ans.find("that") != -1)f = 1;
				if (f)break;
				ans.clear();
			}
			if (f)break;
		}

		cout << ans << endl;
	}
}

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

int trans[26];


void makelist(int a,int b){
	for(int i=0;i<26;i++){
		trans[i]=(a*i+b)%26;
	}
}

string translate(string s){
	for(int i=0;i<s.size();i++){
		if(s[i]>='a' && s[i]<='z'){
			s[i]=trans[s[i]-'a']+'a';
		}
	}
	return s;
}

int main(){
	//a!=2,13 **
	int n;
	cin>>n;
	cin.ignore();
	for(int count=0;count<n;count++){
		string s;
		getline(cin,s);
		string tmp=s;
		int a=0,b=100;
		while(s.find("that")==string::npos && s.find("this")== string::npos){
			b++;
			if(b>=26){
				b=0;
				a++;
			}
			
			while(a%2==0||a%13==0)a++;
			makelist(a,b);
			s=translate(tmp);
			//cout<<s<<endl;
		}
		cout<<s<<endl;
	}
}

C++: #include<stdio.h>
#include<string.h>
int main(){
  int n,i,j,k;
  char s[260],c[260];
  scanf("%d",&n);
  fgets(s,260,stdin);
  while(n--){
    fgets(s,260,stdin);
    for(i=1;1;i+=2){
      if(i%13==0)continue;//printf("%d\n",i);
      for(j=0;j<26;j++){
	for(k=0;s[k];k++){
	  if('a'<=s[k]&&s[k]<='z')c[k]=((s[k]-'a')*i+j)%26+'a';
	  else c[k]=s[k];
	}
	if(strstr(c,"that")||strstr(c,"this"))break;
      }
      if(j-26)break;
    }
    printf("%s",c);
  }
  return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
using namespace std;
bool isalphad(char z){
	if(z>='a'&&z<='z')return true;
	else return false;
}
bool isans(string z){
	bool ok=false;
	for(int i=0;i<z.size()-3;i++){
		if(z[i]=='t'&&z[i+1]=='h'&&z[i+2]=='i'&&z[i+3]=='s')ok=true;
		if(z[i]=='t'&&z[i+1]=='h'&&z[i+2]=='a'&&z[i+3]=='t')ok=true;
	}
	return ok;
}
int main(){
	string s,c;
	int n;
	cin>>n;
	for(int u=0;u<n;u++){
		cin.ignore();
		getline(cin,s);
		if(isans(s))cout<<s<<endl;
		else{
		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;
					}
				}
				if(isans(c)){
					ok=true;
					break;
				}
				b++;
				if(b==27)break;
			}
			if(ok)break;
			a++;
			if(a==27)break;
		}
		cout<<c<<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'));
					}
				}
				cout<<endl;
				if (coded.find("that")!=string::npos || coded.find("this")!=string::npos){
					cout<<coded<<endl;
					a=b=26;
				}
			}
		}
	}
	return 0;
}

C++: #include <iostream>
#include <map>
#include <stdio.h>
using namespace std;

int gcd2(int a,int b){
	while(b!=0){
		int w=a%b;
		a=b;
		b=w;
	}
	return a;
}

int main(void){
  int n;cin>>n;
  cin.ignore();
  while(n--){
    string s;
    getline(cin,s);
    bool f=true;
    for(int a=0;f;++a){
      if(gcd2(a,26)!=1) continue;
      for(int b=0;b<26&&f;++b){
        map<char,char> T;
        for(char c='a';c<='z';++c){
          T[((c-'a')*a+b)%26+'a']=c;
        }
        string s1;
        for(int i=0;i<s.size();++i)s1+=('a'<=s[i]&&s[i]<='z')?T[s[i]]:s[i];
        //cerr<<s1<<endl;
        if(s1.find("this") != -1|| s1.find("that") != -1){cout<<s1<<endl;f=false;}
      }
    }
  }
  return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

map<char,char>mp[26][26];
int main(){
	for(int i=1;i<26;i+=2){
		rep(j,26){
			rep(k,26){
				mp[i/2][j][(k*i+j)%26+'a']=k+'a';
			}
		}
	}
	int n;scanf("%d\n",&n);
	rep(i,n){
		p:;
		string s;getline(cin,s);
		rep(i,26/2){
			rep(j,26){
				string copy=s;
				for(char&c:copy){
					if(isalpha(c)){
						c=mp[i][j][c];
					}
				}
				if((int)copy.find("this")>=0||(int)copy.find("that")>=0){
					cout<<copy<<endl;
					goto p;
				}
			}
		}
	}
}