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;
int main(){
	int n;
	int a[] = {1,3,5,7,9,11,15,17,19,21,23,25};
	cin >>n;
	cin.ignore();
	while(n--){
		string word;
		getline(cin,word);
		for(int i=0; i<12; i++){
			for(int j=0; j<26; j++){
				string affine = word;
				for(int k=0; k<(int)word.size(); k++){
					if(affine[k]>='a' && affine[k]<='z'){affine[k] = (a[i]*(affine[k]-'a')+j)%26+'a';}
				}
				if(affine.find("this")+1 || affine.find("that")+1){
					cout<<affine<<endl;
					goto label;
				}
			}
		}
		label:
	}
	return 0;
}

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

using namespace std;

void solve()
{
	int n;
	scanf("%d\n", &n);
	for(int i = 0; i < n; ++i)
	{
		string str;
		getline(cin, str);
		string temp = str;
		bool flag = true;
		int count = 0;
		while(flag)
		{
			for(int i = 0; i <= 26; ++i)
			{
				if(temp.find("this") != temp.npos || temp.find("that") != temp.npos)
				{
					cout << temp << endl;
					flag = false;
					break;
				}
				else
				{
					for(int j = 0; j < str.size(); ++j)
					{
						if('a' <= str[j] && str[j] <= 'z')
						{
							temp[j] = ((str[j] - 'a') * count + i) % 26 + 'a';
						}
					}
				}
			}
			++count;
		}
	}
}

int main()
{
	solve();
	return(0);
}

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

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

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

const int MOD = 26;

int main(void){
    int n; cin >> n;
    cin.ignore();

    while(n--){
        string cipher;
        getline(cin, cipher);

        string plain = cipher;
        bool ok = false;

        rep(a, 100){
            rep(b, 100){
                if(ok) break;

                plain = cipher;
                rep(i, cipher.size()){
                    if(plain.at(i) != ' ') plain[i] = ((a * (cipher[i] - 'a') + b) % MOD) + 'a';
                }

                if(plain.find("that") != -1 || plain.find("this") != -1) ok = true;
            }
        }

        cout << plain << endl;
    }

	return 0;
}

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

char dec(int a, int b, char c)
{
	if(c==' ')
		return ' ';

	int tmp = c - 'a';
	return 'a'+((a*tmp+b)%26);
}

int main(void)
{
	int i, j, n;
	cin >> n;
	string str;
	string ans = "";
	getline(cin,str);

	for(i=0; i<n; i++)
	{
		getline(cin,str);
		int a = 0, b = 0;
		for(a=0; a<26; a++){
			for(b=0; b<26; b++){
				for(j=0; j<str.size(); j++)
				{
					ans += dec(a,b,str[j]);
				}

				string::size_type index;
				index = ans.find("this");
				if(index != string::npos)
				{
					cout << ans << endl;
					ans = "";
					continue;
				}

				index = ans.find("that");
				if(index != string::npos)
				{
					cout << ans << endl;
					ans = "";
					continue;
				}
				ans = "";
			}
		}
	}
	return 0;
}

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

#define N 26
using namespace std;

main(){
  int n;
  string data[150];
  string tmp[150];
  cin >> n;
  for(int i=0;i<n;i++){
    int size;
    for(size=0;;size++){
      cin >> data[size];
      char c;
      scanf("%c", &c);
      if(c=='\n'){
	break;
      }
    }
    size++;
    for(int i=3;i<N;i+=2){
      if(i%13==0) continue;
      for(int j=0;j<N;j++){
	for(int k=0;k<size;k++){
	  tmp[k]="";
	}
	for(int a=0, b=0;a<size;b++){
	  if(data[a].size()<=b){
	    a++;
	    b=-1;
	    continue;
	  }
	  char c=(char)((i*(int)(data[a][b]-'a')+j)%26);
	  c+='a';
	  tmp[a]+=c;
	}
	for(int k=0;k<size;k++){
	  if(tmp[k]=="that" || tmp[k]=="this"){
	    for(int l=0;l<size;l++){
	      cout << tmp[l];
	      if(l==size-1) cout << endl;
	      else cout << ' ';
	    }
	  }
	}
      }
    }
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <math.h>
#include <map>
#include <stdio.h>
#include <ctype.h>
#include <algorithm>
#include <stdlib.h>

using namespace std;

int main() {
    string y;
    
    int z[12]={1,3,5,7,9,11,15,17,19,21,23,25};
    
    int affine[12*26][26]={0};
    for(int a=0; a<12; a++){
        for(int b=0; b<26; b++){
            for(int i=0; i<26; i++){
                    affine[a*26+b][(i*z[a]+b)%26]=i;
            }
        }
    }
    
    int temp;
    cin>>temp;
    getline(cin,y);
    for(int t=0; t<temp; t++){
        getline(cin,y);
        string x=y;
        
        
        for(int j=0; j<12*26; j++){
            if(x.find("this")!=-1 || x.find("that")!=-1){
                cout<<x<<endl;
                break;
            }
            for(int i=0; i<(int)y.length(); i++){
                if(y[i]==' '){
                    
                }else{
                    x[i]=affine[j][y[i]-'a']+'a';
                }
            }
        }
    
        
        
    }
    
    
    
    return 0;
}

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

int main() {
	string s;
	int q;
	cin >> q;
	for(int i = 0; i < q + 1; ++i){
		getline(cin, s);
		string t = s;
		for(int x = 1; x <= 26; ++x){
			for(int y = 1; y <= 26; ++y){
				if(t.find("that") != string::npos || t.find("this") != string::npos){
					cout << t << endl;
					goto end;
				}
				else{
					for(int j = 0; j < s.size(); ++j){
						if('a' <= s[j] && s[j] <= 'z')
							t[j] = ((((s[j] - 'a') * x + y)) % 26) + 'a';
					}
				}
			}
		}
		end:;
	}
	return 0;
}