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<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
#include<map>
#include<cmath>
#include<complex>
using namespace std;

typedef complex<double> P;

#define X real()
#define Y imag()
typedef int kz;

kz gcd(kz a,kz b) { if(b==0) return a; else gcd(b,a%b); }

int main(){
    int mod=1000000007;
    int n,len,x,y;
    char s[260];
    scanf("%d",&n);
    while (fgets(s,260,stdin)!=NULL) {
        len=strlen(s)-1;
        bool flg=0;
        for (int a=0;a<26;++a) {
            if (gcd(a,26)!=1) continue;
            for (int b=0;b<26;++b) {
                char chk[len];
                for (int c=0;c<len;++c) {
                    if (isalpha(s[c])) {
                        chk[c]=(((s[c]-'a')*a+b)%26)+'a';
                    }
                }
                for (int d=0;d<len;++d) {
                    if (!strncmp(&chk[d],"this",4) || !strncmp(&chk[d],"that",4)) {
                        x=a;
                        y=b;
                        flg=1;
                    }
                }
            }
        }
        char ans[len];
        for (int i=0;i<len;++i) {
            if (isalpha(s[i])) ans[i]=(((s[i]-'a')*x+y)%26+'a');
            else ans[i]=s[i];
        }
        if (flg) printf("%s\n",ans);
        flg=0;
    }
    return 0;
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(c,i) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

string decrypt(const string& c,int a,int b)
{
	int table[26];
	rep(i,26)
		table[(a*i+b)%26]=i;
	string res=c;
	rep(i,c.size())
		if(islower(c[i]))
			res[i]=table[c[i]-'a']+'a';
	return res;
}

int main()
{
	int n;
	cin>>n;
	cin.get();
	rep(loop,n){
		string c;
		getline(cin,c);
		repi(i,1,26){
			if(i==2 || i==13)
				continue;
			rep(j,26){
				string d=decrypt(c,i,j);
				string temp=" "+d+" ";
				if(temp.find(" that ")!=string::npos || temp.find(" this ")!=string::npos){
					cout<<d<<endl;
					goto end;
				}
			}
		}
		end:
		;
	}
	
	return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
  int n;
  cin >> n;
  getchar();
  for(int i = 0; i < n; i++){
    string s,ss;
    getline(cin,s);
    bool f = true;
    for(int a = 0; f; a++){
      for(int b = 0; b < 26; b++){
	ss = s;
	for(int j = 0; j < (int)s.size(); j++){
	  if(s[j] != ' '){
	    ss[j] = ((s[j]-'a') * a + b) % 26 + 'a';
	  }
	}
	if((int)ss.find("this") != -1 || (int)ss.find("that") != -1){
	  f = false;
	  break;
	}
      }
    }
    cout << ss << endl;
  }
}

C++: #include<iostream>
#include<string>
#include<stdio.h>
#include<ctype.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	string a;
	char b[500];
	for(int u=0;u<n;u++){
		cin.ignore();
		getline(cin,a);
		int c=0;
		bool end=false;
		while(true){
		for(int i=0;i<a.size();i++){
			if(isalpha(a[i])!=0)
			    b[i]=((a[i]-'a')*c)%26+'a';
			else
				b[i]=a[i];
		}
		int d=0;
		while(true){
			for(int i=0;i<a.size()-3;i++){
				if(b[i]=='t'&&b[i+1]=='h'&&((b[i+2]=='i'&&b[i+3]=='s')||(b[i+2]=='a'&&b[i+3]=='t'))){
					end=true;
					break;
				}
			}
			if(end==true)
				break;
			for(int i=0;i<a.size();i++){
				if(isalpha(b[i])!=0){
					b[i]++;
					if(b[i]>'z')
						b[i]='a';
				}
			}
			d++;
			if(d==100)
				break;
		}
		if(end==true)
			break;
		c++;
		if(c==100)
			break;
		}
		for(int i=0;i<a.size();i++)
			cout<<b[i];
		cout<<endl;
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;




int main(){


    int n;
    string s;
    cin >> n;
    

    while(n--){
        //cout << n << endl;
        
        getline(cin,s);
        //cout << s << endl;

        for(int i = 1;i < 26;i++){
            
            for(int j = 0;j < 26;j++){

                string t = s;

                for(int k = 0;k < t.length();k++){

                    if(islower(t[k])){

                        t[k] = ((t[k]-'a')*i + j) % 26 + 'a';
                    }

                }
                if(t.find("this") != -1 || t.find("that") != -1){
                    cout << t << endl;
                    i = j = 30;
                }

            }
        }
    }


    return 0;

}

C++: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	int i,n;
	scanf("%d\n",&n);
	for(i=0;i<n;i++){
		string str;
		char s[300];
		gets(s);
		str=s;
//cout<<str<<endl;
		int a,b;
		for(a=1;a<26;a+=2){
			if(a==13)continue;
			for(b=0;b<26;b++){
				string st="";
				int j;
				for(j=0;j<str.size();j++){
					if('a'<=str[j]&&str[j]<='z')){
						st+=((str[j]-'a')*a+b)%26+'a';
					}else{
						st+=str[j];
					}
				}
//if(st[0]=='i')cout<<st<<endl;
				string::size_type index1=st.find("that");
				string::size_type index2=st.find("this");
				if(index1!=string::npos||index2!=string::npos){
					cout<<st<<endl;
					goto end;
				}
			}
		}
		end:;
	}
	return 0;
}