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>
using namespace std;

char T[27] = "abcdefghijklmnopqrstuvwxyz";

string S, V;
int n;
int x[26];

int main() {
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		S = "";
		while (S == "") {
			getline(cin, S);
		}
		for (int j = 0; j < 26; j++)
		{
			for (int k = 0; k < 26; k++)
			{
				for (int l = 0; l < 26; l++)
				{
					x[l] = -1;
				}
				for (int l = 0; l < 26; l++)
				{
					if (x[(j*l + k) % 26] == -1)
					{
						x[(j*l + k) % 26] = l;
					}
					else
					{
						goto E;
					}
				}
				V = "";
				for (int l = 0; l < S.size(); l++)
				{
					for (int m = 0; m < 26; m++)
					{
						if (T[m] == S[l])
						{
							V += T[x[m]];
							goto G;
						}
					}
					V += S[l];
				G:;
				}
				for (int i = 0; i < S.size() - 3; i++)
				{
					if (V.substr(i, 4) == "this" || V.substr(i, 4) == "that")
					{
						cout << V << endl;
						goto H;
					}
				}
			E:;
			}
		}
	H:;
	}
	return 0;
}

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

using namespace std;

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

int main(){
	int n;
	cin >> n;
	cin.ignore();
	for(int i=0;i<n;i++){
		int alpha = 1;
		int beta = 0;
		string str;
		getline(cin, str);
		string tmp = str;

		while(str.find("this")==string::npos && str.find("that")==string::npos){
			str = tmp;
			beta++;
			if(beta>30){
				alpha++;
				beta=0;
			}
			for(int j=0;j<str.size();j++){
				if(str[j]>='a' && str[j]<='z'){
					str[j]=F(alpha, beta, str[j]);
				}
			}
			//cin >> str;
			//cout << alpha <<" "<<beta<<" "<<str <<endl;
		}
		cout << str <<endl;
	}
	return 0;
}

C++: #include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int a, b;

void check(int A[], char inp[]){
    int k;
    rep(i, 500){
        rep(j, 500){
            if((i * A[0] + j) % 26 == inp[0] - 'a'){
                for(k = 1; k < 4; k++){
                    if((i * A[k] + j) % 26 != inp[k] - 'a') break;
                }
            }
            if(k == 4){
                a = i;
                b = j;
                return;
            }
        }
    }
}

int main(){
    char str[356][356];
    char inp[356];
    int len,n,l;
    int This[4] = {19, 7, 8, 18}, That[4] = {19, 7, 0, 19};
    while(cin >> n){
        rep(i,n){
            len = 0;
            a = b = -1;
            while(cin >> inp){
                strcpy(str[len], inp);
                len++;
                if(strlen(inp) == 4){
                    check(This, inp);
                    if(a == -1)
                        check(That, inp);
                }
            }
            rep(j,len){
                rep(k, strlen(str[j])){
                    rep(l,26){
                        if((a * l + b) % 26 == str[j][k] - 'a'){
                            printf("%c",'a' + l);
                        }
                    }
                }
                cout << ' ';
            }
            cout << endl;
        }
    }
}

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

char encode(char x,int a,int b){
	return ( ( a * (x-'a') + b) % 26 ) + 'a';
}

char decode(char x, int a, int b){
	int t = ( x - 'a') - b;
	while( (t%a) != 0 ) t += 26;
	return (t/a) % 26 + 'a';
}

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

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

int main(){
	int n=1;
	int a[12] = {1,3,5,7,9,11,15,17,19,21,23,25};
	
	string str, s;
	cin >> n;
	getline( cin , str );
	
	for(int i=0 ; i<n ; ++i){
		bool flag = false;
		getline( cin , str );

		for(int i=0 ; i<12 ; ++i){
			for(int j=0 ; j<26 ; j++){
				s = decode( str , a[i] , j );
				if( s.find("this") != string::npos || s.find("that") != string::npos ){
					flag = true;
					break;
				}
			}
			if( flag ) break;
		}
		cout << s << endl;
	} 
}

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

int n;

int main(){
    cin >> n;
    cin.ignore();
    while(n--){
        vector<string> str;
        string tmp;
        getline(cin,tmp);
        stringstream ss;
        ss << tmp;
        while(ss >> tmp) str.pb(tmp);
        int a = 0, b = 0;
        rep(i,str.size())if(str[i].size() == 4){
            repi(j,3,26*26)if(__gcd(j,26) == 1){
                rep(k,26){
                    string s = "this", t = "that";
                    rep(u,4){
                        s[u] = (j * (s[u]-'a') + k) % 26 + 'a';
                        t[u] = (j * (t[u]-'a') + k) % 26 + 'a';
                    }
                    if(s == str[i] || t == str[i]){
                        a = j; b = k;
                        break;
                    }
                }
                if(a) break;
            }
            if(a) break;
        }
        string abc = "abcdefghijklmnopqrstuvwxyz";
        rep(i,26) abc[i] = (a * i + b) % 26 + 'a';
        rep(i,str.size()){
            rep(j,str[i].size()) cout << (char)(abc.find(str[i][j]) + 'a');
            cout << (i==str.size()-1? '\n': ' ');
        }
    }
    return 0;
}

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

using namespace std;

int gcd(int x,int y){
  if(y == 0)return x;
  return gcd(y,x%y);
}

int lcm(int x,int y){
  return (x*y)/gcd(x,y);
}

string affine(string s,int a,int b){
  string news;
  for(int i=0;i<s.length();i++){
    if(!('a'<= s[i] && s[i]<='z') ){
      news+=s[i];
      continue;
    }
    int y = s[i]-'a';
    news+= (char)((a*y+b)%26+'a');
  }
  
  return news;
}


int main(){

  int N;
  string s;
  cin >> N;
  cin.ignore();
  while(N-- > 0){
    getline(cin,s,'\n');
   
    bool fin = false;
    for(int a=1;a<=500;a++){
      if(gcd(a,26) == 1){
	for(int b=1;b<=500;b++){
	  string Ns = affine(s,a,b);	  
	  if(Ns.find("that") != string::npos || Ns.find("This") != string::npos){
	    cout << Ns << endl;
	    fin = true;
	    break;
	  }
	}

	}
	if(fin)break;
    }
    if(!fin)cout << s << endl;


  }
  return 0;
}

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

int main(){
  int n;
  string s;
  cin >> n;
  cin.ignore();
  while(n--){
    getline(cin, s);
    string ans = s;
    for(int i = 0 ; i < 26 ; i++){
      for(int j = 0 ; j < 26 ; j++){
	for(int k = 0 ; k < s.size() ; k++){
	  if(isalpha(s[k])) ans[k] = ((i*s[k]+j)%26)+'a';
	}
	if(ans.find("that")+1 || ans.find("this")+1) goto finish;
      }
    }
  finish:;
    cout << ans << endl;
  }
  return 0;
}