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;

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000007
#define EPS 1E-12

int n;
string tmp;

vector<string> split(const string &str, char delim){
  vector<string> res;
  size_t current = 0, found;
  while((found = str.find_first_of(delim, current)) != string::npos){
    res.push_back(string(str, current, found - current));
    current = found + 1;
  }
  res.push_back(string(str, current, str.size() - current));
  return res;
}

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

  while(n--){
    int alpha, beta;
    vector<string> s;
    string ss;
    getline(cin, ss);
    s = split(ss, ' ');

    vrep(v, s) if((*v).size() == 4){
      bool ok = false;

      rep(a, 26) if(!ok) rep(b, 26){
        string word = *v;
        rep(i, 4){
          word[i] -= 'a';
          word[i] = (word[i] + 26 - b) % 26;
          word[i] = (word[i] * a) % 26;
          word[i] += 'a';
        }
        if(word == "this" || word == "that"){
          alpha = a;
          beta  = b;
          ok = true;
          break;
        }
      }
      if(ok) break;
    }

    vrep(v, s){
      tmp = *v;
      rep(i, tmp.size()){
        tmp[i] -= 'a';
        tmp[i] = (tmp[i] + 26 - beta) % 26;
        tmp[i] = (tmp[i] * alpha) % 26;
        tmp[i] += 'a';
      }
      //      cout << tmp << " ";
      cout << tmp << ((v+1)==s.end() ? "\n" : " ");
    }
    //    cout << "\b" << endl;
  }

  return 0;
}

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

string solve(string cipher)
{
  for ( ; ; ) {
    for (int a = 1; ; ++a) {
      if (__gcd(a, 26) != 1)
	continue;
      bool decrypt = false;
      for (int b = 0; b < 26; ++b) {
	string plain = cipher;
	for (unsigned int i = 0; i < plain.size(); ++i) {
	  if (isalpha(plain[i]))
	    plain[i] = ('a' + ((a * (plain[i]-'a') + b) % 26));
	}
	if (plain.find("that") != string::npos || plain.find("this") != string::npos)
	  return plain;
      }
    }
  }
}

int main()
{
  int n;
  cin >> n;
  string cipher;
  getline(cin, cipher);
  for (int i = 0; i < n; ++i) {
    getline(cin, cipher);
    if (cipher.find_first_of("\n") != string::npos)
      cipher.erase(cipher.end()-1);
    if (cipher.find_first_of("\r") != string::npos)
      cipher.erase(cipher.end()-1);
    cout << solve(cipher) << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <math.h>

#define PREP(i, m, n) for(int i = m; i < n; i++)
#define MREP(i, m, n) for(int i = m - 1; i >= n; i--)

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define X first
#define Y second
#define MP make_pair
#define PB push_back

using namespace std;

map<int, char> number;

bool stringSearch(string input, string *after){
	for(int i = 0; i < 2; i++){
		if(input.find(after[i], 0) != string::npos){
			return true;
		}
	}
	return false;
}

void convert(string *after, string *key, int a, int b){
	for(int i = 0; i < 2; i++){
		for(int j = 0; j < key[i].size(); j++){
			after[i].push_back(number[(a * key[i][j] + b) % 26]);
		}
	}
}

void listConvert(map<char, char> &afterlist, int a, int b){
	for(int i = 0; i < 26; i++){
		afterlist[number[i]] = number[(a * number[i] + b) % 26];
	}
}

bool allSearch(string input, string *key){
	for(int a = 1; a < 26; a++){
		for(int b = 0; b < 26; b++){

			string after[2];
			map<char, char> afterlist;
			convert(after, key, a, b);
			listConvert(afterlist, a, b);

			if(stringSearch(input, after)){
				//文字があったら
				string answer;
				for(int i = 0; i < input.size(); i++){
					if(input[i] != ' '){
						for(map<char, char>::iterator it = afterlist.begin(); it != afterlist.end(); it++){
							if(it->second == input[i]) answer.push_back(it->first);
						}
					}
					else answer.push_back(' ');
				}
				cout << answer << endl;
				return true;
			}

		}
	}
	return false;
}

int main(){
	string key[] = {"this", "that"};
	number[0] = 'a';
	number[1] = 'b';
	number[2] = 'c';
	number[3] = 'd';
	number[4] = 'e';
	number[5] = 'f';
	number[6] = 'g';
	number[7] = 'h';
	number[8] = 'i';
	number[9] = 'j';
	number[10] = 'k';
	number[11] = 'l';
	number[12] = 'm';
	number[13] = 'n';
	number[14] = 'o';
	number[15] = 'p';
	number[16] = 'q';
	number[17] = 'r';
	number[18] = 's';
	number[19] = 't';
	number[20] = 'u';
	number[21] = 'v';
	number[22] = 'w';
	number[23] = 'x';
	number[24] = 'y';
	number[25] = 'z';
	
	int n = 0;
	cin >> n;
	while(n--){
		cin.ignore();
		string input;
		getline(cin, input);
		allSearch(input, key);
	}

	return 0;
}

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

int main()
{
  int n,i,j;
  int alpha[A]={3,5,7,9,11,13,15,17,19,21,23,25},beta;
  string s,t;
  bool f;
  getline(cin,s);
  while(getline(cin,s)){
    f=true;
    for(i=0;f && i<A;i++){
      for(beta=0;f && beta<26;beta++){
	t=s;
	for(j=0;j<t.size();j++){
	  if(t[j]==' ')continue;
	  t[j]-='a';
	  t[j]=((t[j]+beta)*alpha[i])%26;
	  t[j]+='a';
	}
	if(t.find("this ",0)==4)f=false;
	if(t.find("that ",0)==4)f=false;
	if(t.find(" this",t.size()-5)==t.size()-5)f=false;
	if(t.find(" that",t.size()-5)==t.size()-5)f=false;
	if(t.find(" this ")!=string::npos)f=false;
	if(t.find(" that ")!=string::npos)f=false;
      }
    }
    cout<<t<<endl;
  }
}