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>

using namespace std; 
 
map<char, int> c2i;
map<int, char> i2c;
string str;
 
void init()
{
    for (char ch = 'a'; ch <= 'z'; ch++) {
	c2i[ch] = ch - 'a';
	i2c[ch - 'a'] = ch;
    }
}
 
bool serch(string s)
{
    string str;
    stringstream ss(s);
    while (ss >> str) {
        if (str == "this" || str == "that") {
            return 1;
        }
    }
    return 0;
}
 
char F(char ch, int a, int b)
{
    int num = (a * c2i[ch] + b) % 26; 
    return i2c[num];
}
 
int main()
{
    int n;
    init(); 
    cin >> n;
    cin.ignore();
    while (n--) {
	getline(cin, str);
 
	for (int i = 0; i < 26; i++) {
	    for (int j = 0; j < 26; j++) {
		string next;
		for (int k = 0; k < (int)str.size(); k++) {
		    if (islower(str[k])) {
                        next += F(str[k], i, j);
		    } else {
                        next += str[k];
                    }
                }
		if (serch(next)) {
		    cout << next << endl;
                    goto END;
		}
	    }
	}
        END:;
    }
    return 0;
}

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

#define DCRPT_MAX 26

int Alpha;
int Beta; // 0 -> 25
int fCnt;

int F( int g ) {
  return ( Alpha * g + Beta ) % 26;
}

char f( char c ) {
  return F( c - 'a' ) + 'a';
}

string decode( string str, int cnt ) {
  for(int i=0; i<str.size(); i++) {
    for(int j=0; j<cnt; j++) {
      str[i] = f( str[i] );
    }
  }

  return str;
}

string Decrypt( string str, int cnt ) {
  
  for(int i=0; i<str.size(); i++) {
    for(int j=0; j<cnt; j++) {
      if( 'a' <= str[i] && str[i] <= 'z') {
	str[i] = f( str[i] );
      }
    }
  }

  return str;
}

bool affineCipher( vector<string> vec ) {
  
  for( Alpha = 1; Alpha < 26; Alpha ++ ) {
    if( Alpha % 2 == 0 || Alpha % 13 == 0 ) continue;
    for( Beta = 0; Beta < 26; Beta ++ ) {
      for(int i = 1; i < DCRPT_MAX; i ++) {
	for(int j = 0; j < vec.size(); j ++) {
	  string dec = decode( vec[j], i );
	  if( dec == "this" || dec == "that" ) {
	    fCnt = i;
	    return true;
	  }
	}
      }
    }
  }
  
  return false;
}


int main() {
  string cryptogram;
  int tcase;
  
  cin >> tcase; cin.ignore();
  
  for( int i = 0; i < tcase; i ++ ) {
    getline( cin, cryptogram );
    
    vector<string> v;
    stringstream ss( cryptogram );

    while(true) {
      string str;
      ss >> str; if( str == "" ) break;
      if( str.size() == 4 ) {
	v.push_back( str );
      }
    }

    if( affineCipher( v ) ) {
      cout << Decrypt( cryptogram, fCnt ) << endl;
    } else {
      cerr << "Decrypt Failed." << endl;
      exit(EXIT_FAILURE);
    }
  }
  
  return 0;
}

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

string ss, THIS("this"), THAT("that");
int a, b, n;

bool ifincluded(string key, string trg){
    int count = 0;
    string::iterator itkey = key.begin();
    for(string::iterator it = trg.begin(); it != trg.end(); it++){
        if( *it == *itkey ){
            itkey++;
            if( itkey == key.end() ){
                return 1;
            }
        }else{
            itkey = key.begin();
            if( *it == *key.begin() ){
                itkey++;
            }
        }

    }
    return false;
}

int main(){
    cin >> n;
    getline(cin, ss);
    while( n-- > 0 ){
        getline(cin, ss);
        string cs;
        bool ok = false;
        for(a = 1; !ok && a < 26; a++){
            if( a != 1 && 26%a == 0 ) continue;
            for(b = 0; !ok && b < 26; b++){
                cs = ss;
                for(string::iterator it = cs.begin(); it != cs.end(); it++){
                    if( isalpha( *it ) ){
                        *it = ( (*it-'a') * a + b) % 26 + 'a'; 
                    }
                }
                if( ifincluded( THIS, cs ) ||
                    ifincluded( THAT, cs ) ){
                    ok = 1;
                }
            }
        }
        cout << cs << endl;
    }
    return 0;
}

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

int main(){
	int n;
	char str[257] = {}, str_c[257], len;
	cin >> n;
	getchar();
	for (int m = 0; m < n; m++){
		gets(str);
		len = strlen(str);
		//printf("%d\n", len);
		for (int i = 1; i < 26; i++){
			/*if (i % 2 == 0 || i % 13 == 0) continue;*/
			for (int j = 0; j < 26; j++){
				for (int k = 0; k <= len; k++){
					if (isalpha(str[k])){
						str[k] -= 'a';
						str_c[k] = (str[k] * i + j) % 26 + 'a';
						str[k] += 'a';
					}
					else{
						str_c[k] = str[k];
					}
				}
				if (strstr(str_c, "this") || strstr(str_c, "that")){
					printf("%s\n", str_c);
					return 0;
				}
			}
		}
	}
	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",&n);
	while(n--){
		char str[258];
		getchar();
        fgets(str, 258, stdin);
		set < string > target;
		stringstream stre(str);
		string tmp;
		while(stre >> tmp){
			if(tmp.size() == 4){
				target.insert(tmp);
			}
		}
		string ans = "";
		int i = 1;
		int alpha;
		int beta;
		while(i){
			if(i%13 == 0)continue;
			rep(j,26){
				rep(k,2){
					string sub;
					if(k == 0){
						sub = "this";
					}
					if(k == 1){
						sub = "that";
					}
					rep(l,4){
						sub[l] = ((i*(sub[l]-'a')+j) % MOD)+'a';
					}
					if(target.count((string)sub)){
						alpha = i;
						beta = j;
						goto end;
					}
				}
			}
			i += 2;
		}
		end:;
		map < char , char > memo;
		rep(i,26){
			memo[((alpha*i+beta) % MOD)+'a'] = i+'a';
		}
		rep(i,strlen(str)){
			if(str[i] == ' ')ans += " ";
			else ans += memo[str[i]];
		}
		cout << ans << endl;
	}
	return 0;
}