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<cstring>
#include<string>
#include<vector>
using namespace std;

bool isCoprime( int a, int b ){
	while( a != b ){
		if( a > b )	a -= b;
		else		b -= a;
	}
	return a==1;
}

int nextAlpha( int a ){
	while(1){
		if( isCoprime( 26, ++a ) ){
			break;
		}
	}
	return a;
}

bool check( string str, int a, int b ){
	for( int i=0; i<str.length(); i++ ){
		if( 'a'<=str[i]&&str[i]<='z' )	str[i] = ((a*(str[i]-'a')+b) % 26) + 'a';
	}
	if( (str.find("this")!=string::npos)||(str.find("that")!=string::npos) ){
		cout << str << endl;
		return true;
	}
	return false;
}

int main(){
	int n;
	string line;
	
	getline( cin, line );
	sscanf( line.c_str(), "%d", &n );
	
	for( int i=0; i<n; i++ ){
		int a=2, b;
		getline( cin, line );
		for(;;a=nextAlpha(a)){
			for( b=0; b<26; b++ ){
				if( check( line, a, b ) ){
					break;
				}
			}
			if( b < 26 )	break;
		}
	}
	return 0;
}

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

int al[] = { 1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23 };
int alen = 11;

int affine(int a, int b, char y){
	return (a*(y-'a') + b) % 26;
}

int affine(int a, int b, char *d, char *s, int len){
	for(int i=0;i<len; ++i){
		if(s[i] == ' '){
			d[i] = ' ';
		}else{
			d[i] = affine(a, b, s[i]) + 'a';
		}
	}
	d[len] = '\0';
	return 0;
}

bool is_true(char *x, int *a, int *b){
	char tmp[5];
	if(x[0] == x[3]){
		*b = x[2] - 'a';
		*b += *b >= 0 ? 0 : 26;
		for(int i=0; i<alen; ++i){
			if(x[0] - 'a' == affine(al[i], *b, 't')){
				*a = al[i];
				affine(*a, *b, tmp, "that", 4);
				if(strcmp(tmp, x) == 0){
					return true;
				}else{
					return false;
				}
			}
		}
	}else{
		for(int i=0; i<alen; ++i){
			*b = ((x[0]-'a') - ('t'-'a') * al[i]) % 26;
			*b += *b >= 0 ? 0 : 26;
			affine(al[i], *b, tmp, "this", 4);
			if(strcmp(tmp, x) == 0){
				return true;
			}
		}
	}
	return false;
}

void raffine(char *dest, const char *source, int a, int b, int len){
	int table[26];
	for(int i=0; i<26; ++i){
		table[affine(a, b, i+'a')] = i;
	}
	for(int i=0; i<len; ++i){
		if(source[i] == ' ') { 
			dest[i] = ' ';
		}else{
			dest[i] = table[source[i]-'a'] + 'a';
		}
	}
	dest[len] = '\0';
}

int main(void){
	int n;
	char in[257];
	char cin[257];
	char *tmp;
	int len;
	int a=0, b=0;
	bool o = false;

	scanf("%d", &n);
	scanf("%c", in);
	for(int i=0; i<n; ++i){
		fgets(in, 256, stdin);
		len = strlen(in);
		in[--len] = '\0';
		strcpy(cin, in);

		tmp = strtok(cin, " ");
		if(strlen(tmp) == 4){
			if(is_true(tmp, &a, &b)){
				raffine(cin, in, a, b, len);
			}
		}else{
			while((tmp = strtok(NULL, " ")) != NULL){
				if(strlen(tmp) == 4 && is_true(tmp, &a, &b)){
					raffine(cin, in, a, b, len);
					break;
				}
			}
		}
		puts(cin);
	}
	return 0;
}

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

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;
	while (isspace(c)) {c = gcu();}
	if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

using S = string;
using K = pair<int, int>;

void decode(S s, K k) {
	vector<char> t(26);
	for (int i = 0; i < 26; i++)
		t[(i * k.first + k.second) % 26] = i;
	for (char &c: s)
		pcu(islower(c) ? t[c - 'a'] + 'a' : c);
	outl();
}

K attack(S s) {
	S w;
	for (char c: s) {
		if(islower(c))
			w += c;
		else {
			if (w.size() == 4)
				for (int a = 1; a < 26; a += 2)
					if (a != 13) {
						int b = (26 + w[0] - 'a' - ('t' - 'a') * a % 26) % 26;
						auto d = [=](int c) {return ((c - 'a') * a + b) % 26 + 'a';};
						if (w[1] == d('h') &&
							((w[2] == d('a') && w[3] == d('t')) ||
							 (w[2] == d('i') && w[3] == d('s'))))
							return {a, b};
					}
			w = "";
		}
	}
	return {0, 0};
}

int main() {
	for (int n = in(); n; n--) {
		S s;
		getline(cin, s);
		decode(s, attack(s + ' '));
	}
}

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

using namespace std;

int alpha,beta;

char function(char c){

	//文字を数字に変える。
	int num = c-'a';

	int tmp = (alpha*num+beta)%26;

	char ans = (char)tmp + 'a';

	return ans;


}

int main(){
	alpha = 3;
	beta = 2;

	int n;
	cin>>n;

	for(int i=0;i<n;i++){
		string str;
		cin.ignore();
		getline(cin,str);

		char tmp[260];
		int breakFlag=0;
		for(alpha = 0;alpha<26;alpha++){
			for(beta = 0;beta<26;beta++){
				for(int j=0;j<str.size();j++){
					if(str[j]==' '){
						tmp[j] = ' ';
					}
					else{
						tmp[j] = function(str[j]);
					}
				}
				/*
				for(int j=0;j<str.size();j++){
					cout<<tmp[j];
				}
				cout<<endl;
				*/
				for(int j=0;j<str.size()-3;j++){
					if(tmp[j]=='t'&&tmp[j+1]=='h'&&tmp[j+2]=='i'&&tmp[j+3]=='s'){
						breakFlag=1;
						break;
					}
					if(tmp[j]=='t'&&tmp[j+1]=='h'&&tmp[j+2]=='a'&&tmp[j+3]=='t'){
						breakFlag=1;
						break;
					}
				}
				if(breakFlag==1){
					break;
				}
			}
			if(breakFlag == 1){
				break;
			}
		}
	}

	return 0;


}

/*
Sample Input
1
y eazqyp pnop pngtg ye obmpngt xmybp mr lygw
Output for the Sample Input
i submit that there is another point of view
*/

C++: #include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
using namespace std;
int gcd(int s)
{
	for(int i=2;i<26;i++)
	{
		if(s%i==0&&26%i==0)return 1;
	}
	return 0;
}
int main()
{
	int n,a,b,c,len,i,j;
	cin >> n;
	while(getchar()!='\n');
	char str[257],tmp[257],henkan[26];
	for(i=0;i<n;i++)
	{
		fgets(str,sizeof(str),stdin);
		for(a=1;a<26;a++)
		{
			if(gcd(a))continue;
			for(b=1;b<26;b++)
			{
				memset(tmp,'\0',sizeof(tmp));
				for(c=0;c<26;c++)
				{
					henkan[(c*a+b)%26]=c;
				}
				for(j=0;str[j]!='\0'&&str[j]!='\n';j++)
				{
					if(str[j]>='a'&&str[j]<='z')
					{
						tmp[j] = henkan[str[j]-'a']+'a';
					}
					else
					{
						tmp[j] = str[j];
					}
				}
				if(strstr(tmp,"this")||strstr(tmp,"that"))
				{
					cout << tmp << endl;
					a=26;
					break;
				}
			}
		}
	}
	return 0;
}