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 <cstdio>
#include <string>
#include <map>
using namespace std;

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

char decode(char x, int a, int b){
	int t = ( x - 'a') - b;
	while( (t%a) != 0 ) t += 26;
	return (t/a) % 26 + 'a';
}

string encode(string s, int a, int b){
	for(int i =0 ; i<(int)s.size() ; ++i )
		if( s[i] >= 'a' && s[i] <= 'z' )
			s[i] = encode( s[i] , a , b );
	return s;
}

string decode(string s, int a, int b){
	for(int i =0 ; i<(int)s.size() ; ++i )
		if( s[i] >= 'a' && s[i] <= 'z' )
			s[i] = decode( s[i] , a , b );
	return s;
}

int main(){
	int n=1;
	int a[12] = {1,3,5,7,9,11,15,17,19,21,23,25};
	
	string str, s;
	//scanf("%d ", &n);
	cin >> n;
	getline( cin , str );
	
	for(int i=0 ; i<n ; ++i){
		bool flag = false;
		getline( cin , str );
		//char foo[257];
		//gets( foo );
		//str = foo;

		for(int i=0 ; i<12 ; ++i){
			for(int j=0 ; j<26 ; j++){
				s = decode( str , a[i] , j );
				if( s.find("this") != string::npos || s.find("that") != string::npos ){
					flag = true;
					break;
				}
			}
			if( flag ) break;
		}
		//printf("%s\n" , s.c_str() );
		cout << s << endl;
	} 
}

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--){
		getchar();
		string str;
		getline(cin,str);
		set < string > target;
		stringstream stre(str);
		string tmp;
		while(stre >> tmp){
			if(tmp.size() == 4){
				target.insert(tmp);
			}
		}
		/*
		rep(i,str.size()-3){
			string sub(str,i,4);
			if(i == 0){
				if(str[4] == ' ' || str[4] == '\0'){
					if(str[0] != ' '&&str[1] != ' '&&str[2] != ' '&&str[3] != ' '){
						target.insert(sub);
					}
				}
			}
			else if(i == str.size()-4){
				if(str[str.size()-5] == ' '){
					if(str[i] != ' '&&str[i+1] != ' '&&str[i+2] != ' '&&str[i+3] != ' '){
						target.insert(sub);
					}
				}
			}
			else{
				if(str[i-1] == ' ' && str[i+4] == ' '){
					if(str[i] != ' '&&str[i+1] != ' '&&str[i+2] != ' '&&str[i+3] != ' '){
						target.insert(sub);
					}
				}
			}
		}
		*/
		string en = "abcdefghijklmnopqrstuvwxyz";
		string ans = "";
		int i = 0;
		int alpha;
		int beta;
		while(++i){
			if(i%2 == 0 || 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] = en[((i*(sub[l]-'a')+j) % MOD)];
					}
					if(target.count(sub)){
						alpha = i;
						beta = j;
						goto end;
					}
				}
			}
		}
		end:;
		map < char , char > memo;
		rep(i,26){
			memo[en[((alpha*i+beta) % MOD)]] = en[i];
		}
		rep(i,str.size()){
			if(str[i] == ' ')ans += " ";
			else ans += memo[str[i]];
		}
		cout << ans << endl;
	}
	return 0;
}

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

int trans[26];


void makelist(int a,int b){
	for(int i=0;i<26;i++){
		trans[i]=(a*i+b)%26;
	}
}

string translate(string s){
	for(int i=0;i<s.size();i++){
		if(s[i]>='a' && s[i]<='z'){
			s[i]=trans[s[i]-'a']+'a';
		}
	}
	return s;
}

int main(){
	//a!=2,13 **
	int n;
	cin>>n;
	for(int count=0;count<n;count++){
		string s;
		cin.ignore();
		getline(cin,s);
		string tmp=s;
		int a=1,b=-1;
		while(s.find("that")==string::npos && s.find("this")== string::npos){
			b++;
			if(b==26){
				b=0;
				a++;
			}
			while(a%2==0||a%13==0)a++;
			makelist(a,b);
			s=translate(tmp);
			//cout<<s<<endl;
		}
		cout<<s<<endl;
	}
}

C++: #include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>

using namespace std;

int A;
int B;

void th(char before[]){
    int alpha[]={1,3,5,7,9,11,15,17,19,21,23,25};
    int str_int;
    char str[5];
    for(int i=0;alpha[i]<26;i++){
        for(int j=0;j<26;j++){
            for(int k=0;k<4;k++){
                str_int=(int)(before[k]-'a');
                str[k]=(char)((alpha[i]*str_int+j)%26)+'a';
            }
            str[4]='\0';
            if(strcmp(str,"that")==0||strcmp(str,"this")==0){
                A=alpha[i];
                B=j;
                return;
            }
        }
    }
    return;
}

char complex(char before){
    int str_int;
    char str;
    str_int=(int)(before-'a');
    str=(char)((A*str_int+B)%26+'a');
    return (str);
}

int main(void){
    char before[257][257],after[257][257];
    int len;
    int n;
    
    cin>>n;
    for(int l=0;l<n;l++){
    int i=0;
    while(scanf("%s",before[i])){
        if(strlen(before[i])==4){
            th(before[i]);
        }
        i++;
        if(getchar()=='\n')break;
    }
    for(int j=0;j<i;j++){
        len=strlen(before[j]);
        for(int k=0;k<len;k++){
            after[j][k]=complex(before[j][k]);
        }
        after[j][len]='\0';
        printf("%s",after[j]);
        if(j!=i-1)printf(" ");
    }
    printf("\n");
    }
    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++){
				t=s;
				for(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:;}
}