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.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, 1000){
        rep(j, 1000){
            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 n,i;
    int This[4] = {19, 7, 8, 18}, That[4] = {19, 7, 0, 19};
    while(cin >> n){
        rep(i,n){
            a = b = -1;
            for(i = 0; cin >> inp; i++){
                strcpy(str[i], inp);
                if(strlen(inp) == 4){
                    check(This, inp);
                    if(a == -1)
                        check(That, inp);
                }
            }
            rep(j,i){
                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;

int alpha,beta;

char f(int c) {
    if(c == ' ') return ' ';
    return (char)(((alpha*c+beta)%26)+'a');
}

int main() {
    int n;
    string in;
    cin>>n;
    cin.ignore();
    while(n--) {
        getline(cin, in);
        for(alpha = 2; alpha<26; ++alpha) {
            if(26%alpha == 0) continue;

            for(beta = 0; beta <26; ++beta) {
                string ci = in;
                for(int i=0; i<ci.length(); ++i)
                    ci[i] = f(ci[i]);


                if(ci.find("this") != string::npos || ci.find("that") != string::npos) {
                    cout<<ci<<endl;
                    goto END;
                }
            }
        }
    END:;
    }
}

C++: #include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
string change(int a,int b,string str){
    for(int i=0;i<str.size();i++)str[i]=((str[i]-'a')*a+b)%26+'a';
    return str;
}
string out(int a,int b,string str){
    for(int i=0;i<str.size();i++){
        if('a'<=str[i]&&str[i]<='z'){
            for(int j=0;j<26;j++){
                if((j*a+b)%26+'a'==str[i]){
                    str[i]=j+'a';
                    break;
                }
            }
        }
    }
    return str;
}
int main(){
    int N;
    cin>>N;
    for(int i=0;i<N;i++){
        string str;
        getchar();
        getline(cin,str);
        for(int j=1;;j++){
            for(int k=0;k<26;k++){
                for(int l=0;l<str.size()-3;l++){
                    if(change(j,k,"that")==str.substr(l,4)){
                        cout<<out(j,k,str)<<endl;
                        goto exit;
                    }
                    if(change(j,k,"this")==str.substr(l,4)){
                        cout<<out(j,k,str)<<endl;
                        goto exit;
                    }
                }
            }
        }
    }
exit:
    return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

string change(string s,int a,int b){
	string ret(s);
	rep(i,0,ret.size()){
		int y=ret[i]-'a';
		y=(a+y+b)%26;
		ret[i]='a'+y;
	}
	return ret;
}

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

int main(){
	int n;
	cin>>n;
	string str[2]={"that","this"};
	rep(i,0,n){
		string s;
		bool f=0;
		getline(cin,s);
		rep(a,0,26){
			if(gcd(a,26)!=1) continue;
			rep(b,0,26){
				string t;
				t=change(s,a,b);
				rep(j,0,2){
					if(t.find(str[j]) != string::npos){
						o(t); f=1; break;
					}
				}
				if(f) break;
			}
			if(f) break;
		}

	}
}

C++: #include <iostream>
#include <string>
using namespace std;
int gcd(int a,int b){
  int c;
  while(a){
    c=b%a;
    b=a;
    a=c;
  }
  return b;
}
int main(){
  int n;
  string c;
  cin>>n;cin.ignore();
  while(n--){
    getline(cin,c);
    bool flag=false;
    for(int i=1;i<26;i++){
      if(gcd(i,26)!=1) continue;
      for(int j=0;j<26;j++){
	string p;
	for(string::iterator it=c.begin();it!=c.end();it++){
	  if(*it==' '){
	    p+=*it;
	  }
	  else p+=(char)(((int(*it)-'a')*i+j)%26+'a');
	}
	if(p.find("this")!=string::npos||p.find("that")!=string::npos){
	  cout<<p<<endl;
	  flag=true;
	  break;
	}
      }
      if(flag) break;
    }
  }
  return 0;
}

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

bool isPrimary(int num) {
    return(num % 2 != 0 && num % 13 != 0);
}
char calc(int a, int b, char chr) {
    int num = chr - 'a';
    char ret = 'a' + ((num * a + b) % 26);
    return(ret);
}

int main(void) {
    int num; string input;
    cin >> num; //cout << num << endl;
    cin.ignore(1, '\n');
    for(int r = 0; r < num; r++) {
        getline(cin, input); //cout << input << endl;
        bool found = false;
        for(int a = 0; !found; a++) {
            if(!isPrimary(a)) continue;
            for(int b = 0; b < 26 && !found; b++) {
                for(int r = 0; r < input.length(); r++) {
                    if(!isalpha(input[r])) continue;
                    input[r] = calc(a, b, input[r]);
                }
                if((input.find("this") != string::npos) || (input.find("that") != string::npos)) {
                    found = true;
                }
            }
        }
        cout << input << endl;
    }
    return(0);
}