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;

main(){
  int n;
  string data[100];
  string tmp[100];
  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<26;i+=2){
      if(i==13) continue;
      for(int j=0;j<26;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;
	  }
	}
      }
    }
  }
  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 = 0; a <= 25; a++){
		for(int b = 0; b <= 25; 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 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 <string>
#include <iostream>
using namespace std;
int main(){
	int N,a,b,i,c;
	string s,t;
	for(cin>>N,getline(cin,s);N--;){
		getline(cin,s);
		for(a=1;a<26;a++){
			if(a%2==0||a%13==0)continue;
			for(b=0;b<26;b++){
				for(t=s,i=0;i<t.length();i++){
					if(t[i]<'a'||'z'<t[i])continue;
					c=t[i]-'a'+b;for(;c%a;)c+=26;
					t[i]=c/a%26+'a';
				}
				if(t.find("this")!=-1||t.find("that")!=-1){cout<<t<<endl;goto n;}
			}
		}	
	n:;}
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
typedef vector <string> vs;
#define REP(i,n) for (int i=0; i<n; i++)
string A2Z="abcdefghijklmnopqrstuvwxyz";
struct affine_key{
	int a;
	int b;
};

string decode(string &L1, string &L2, string &msg){
	int n=msg.size();
	string s="";
	REP(i,n){
		char c=msg[i];
		if (c>='a' && c<='z'){
			string::size_type index=L1.find(c);
			s += L2[index];
		}else
			s += c;
	}
	return s;
}

string affine(string &msg, affine_key &key){
	string s="", s2;
	REP(i,26){
		int it=(i*key.a+key.b+26)%26;
		s += A2Z[it];
	}
	return decode(A2Z, s, msg);
}

string rot(string &msg, int a){
	if (a==0) return msg;
	while (a<0)
		a+= 26;
	a %= 26;
	string s = A2Z.substr(a)+A2Z.substr(0,a);
	return decode(A2Z, s, msg);
}

affine_key find(string &msg){
	char c0='t';
	affine_key key;
	for (int i=1; i<26; i+=2){
			key.a=i;
			key.b=0;
		string x=affine(msg, key);
		int a = c0-x[0];
		if (a<0) a += 26;
		x = rot(x,a);
		if (x=="this" || x=="that"){
			key.b=a;
			return key;
		}
	}
	key.a=-1;
	key.b=-1;
	return key;
}

vs split(const string &text, char delim=' '){
    int p1 = 0, p2 = 0;
    vs tokens;
 
    for (int i=0; i<(int)text.size(); i++)
        if (text[i] == delim){
            p2 = i;
            tokens.push_back(text.substr(p1, p2 - p1));
            p1 = p2 + 1;
        }
    tokens.push_back(text.substr(p1));
    return tokens;
}

int main(void){
	int n;
	cin>>n;
	REP(i,n){
		string msg;
		getline(cin, msg);
		vs word = split(msg);
		affine_key key;
		REP(i, word.size())
			if (word[i].size()==4){
				key = find(word[i]);
				if (key.a != -1) break;
			}
			cout<<msg<<endl;
			cout<<affine(msg, key)<<endl;
	}
}

C++: #include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
  int n;
  cin >> n;
  for(int i = 0; i < n; i++){
    string s,ss;
    getchar();
    getline(cin,s);
    bool f = true;
    for(int a = 0; f; a++){
      for(int b = 0; b < 26; b++){
	ss = s;
	for(int j = 0; j < (int)s.size(); j++){
	  if(s[j] != ' '){
	    ss[j] = ((s[j]-'a') * a + b) % 26 + 'a';
	  }
	}
	if((int)ss.find("this") != -1 || (int)ss.find("that") != -1){
	  f = false;
	  break;
	}
      }
    }
    cout << ss << endl;
  }
}

C++: #include <stdio.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int inv[26];

bool ok(const string& t) {
    if (t.find("that") != string::npos) return true;
    if (t.find("this") != string::npos) return true;
    return false;
}

string decode(const string& s) {
    rep (a, 26) if (a % 2 != 0 && a % 13 != 0) {
        rep (b, 26) {
            string t(s);
            rep (i, s.size()) if (islower(s[i])) {
                t[i] = 'a' + (s[i]-'a'+b)*inv[a] % 26;
            }
            if (ok(t)) return t;
        }
    }
    return "";
}

int main() {
    rep (i, 26) {
        int k = 1;
        rep (_, 11) k = (k*i)%26;
        inv[i] = k;
    }
    string s;
    getline(cin, s);
    int T = atoi(s.c_str());
    while (T--) {
        getline(cin, s);
        if (s.size() && s[s.size()-1] == '\r') s.resize(s.size()-1);
        cout << decode(s) << endl;
    }
    return 0;
}