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 <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <memory.h>
#include <cassert>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;

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

int main() {
	int n; cin >> n;
	getchar();
	while (n--) {
		string s; getline(cin, s);
		int ca[26], cb[26];
		memset(ca, 0, sizeof(ca));
		rep(a, 1000000000) if (gcd(a, 26) == 1) if (ca[a % 26] == 0) {
			ca[a % 26] = 1;
			int cnt = 26;
			memset(cb, 0, sizeof(cb));
			rep(b, 1000000000) {
				if (cb[b % 26]) continue;
				cnt--;
				string t = s;
				rep(i, t.size()) if (isalpha(t[i])) t[i] = (a * (t[i] - 'a') + b) % 26 + 'a';
				if(t.find("that") != -1 || t.find("that") != -1) {
					cout << t << endl;
					goto next;
				}
				cb[b % 26] = 1;
				if(!cnt) break;
			}
		}
		next:;
	}
	
	return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<string.h>

int main()
{
	int n;
	std::cin >> n;
	
	while( n-- ){
		char s[260], t[260];
		char a[29];
		
		fgets( s, 257, stdin );
		
		strcpy( t, s );
		
		for( int i = 1; i <= 26; i += 2 ){
			for( int j = 0; j < 26; j++ ){
				if( i % 13 == 0 ) continue;
				
 				for( int k = 0; k < 26; k++ ){
				 	a[ ( i * k + j ) % 26 ] = k + 'a';
				}
				
				for( int k = 0; k < strlen( t ); k++ ){
					if( s[k] >= 'a' && s[k] <= 'z' ){
						s[k] = a[ t[k] - 'a' ];
					}
				}
				
				if( strstr( s, "that" ) != NULL || strstr( s, "this" ) != NULL ){
					std::cout << s;
				}
				
				strcpy( s, t );
			}
		}
	}

 	return 0;
}

C++: #include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<numeric>
using namespace std;
const int dx[]={1,0,-1,0};
const int dy[]={0,1,0,-1};
#define INF 1e+8
#define EPS 1e-7
#define PB push_back
#define fi first
#define se second
#define ll long long
#define MOD 26
#define reps(i,j,k) for(int i = (j); i < (k); i++)
#define rep(i,j) reps(i,0,j)
typedef pair<int,int> Pii;
typedef vector<int> vi;
int main(){
    int n;
    scanf("%d%*c",&n);
    while(n--){
        string str;
        getline(cin,str);
        vector < string > target;
        rep(i,str.size()-3){
            string sub(str,i,4);
            if(i == 0){
                if(str[4] == ' ' || str[4] == '\0'){
                    if(str[0] != ' '&&str[1] != ' '&&str[2] != ' '&&str[3] != ' '){
                        target.PB(sub);
                    }
                }
            }
            else if(i == str.size()-4){
                if(str[str.size()-5] == ' '){
                    if(str[i] != ' '&&str[i+1] != ' '&&str[i+2] != ' '&&str[i+3] != ' '){
                        target.PB(sub);
                    }
                }
            }
            else{
                if(str[i-1] == ' ' && str[i+4] == ' '){
                    if(str[i] != ' '&&str[i+1] != ' '&&str[i+2] != ' '&&str[i+3] != ' '){
                        target.PB(sub);
                    }
                }
            }
        }
        string en = "abcdefghijklmnopqrstuvwxyz";
        string ans = "";
        int i = 0;
        int alpha;
        int beta;
        while(++i){
            if(i%2 == 0 || i%13 == 0)continue;
            rep(j,26){
                rep(k,target.size()){
                    string sub;
                    rep(l,4){
                        sub += en[((i*(target[k][l]-'a')+j) % MOD)];
                    }
                    if(sub == "this" || sub == "that"){
                        alpha = i;
                        beta = j;
                        goto end;
                    }
                }
            }
        }
        end:;
        rep(i,str.size()){
            if(str[i] == ' ')ans += " ";
            else ans += en[((alpha*(str[i]-'a')+beta) % MOD)];
        }
        cout << ans << endl;
    }
    return 0;
}

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;
        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;
                    }
                }
            }
        }
        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];
        }
        printf("%s\n",ans);
    }
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  int i,j,k,l;
  string s,o;
  getline(cin,s);
  while(n--){
    getline(cin,s);
    bool f =false;
    
    for(i=1;i<26;i++){
      if(f) break;
      if(i%2==0||i%13==0) continue;
      for(j=0;j<26;j++){
	o=s;
	for(k=0;k<s.size();k++){
	  if(s[k]==' ') continue;
	  o[k]=(((s[k]-'a')*i+j)%26)+'a';
	}
	
	if(o.find("this")!=-1||o.find("that")!=-1)
	  f=true;
	
	if(f){
	  cout << o << endl;
	  break;
	}
      }
    }
  }
  
  return 0;
}