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 <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 + 'a';
	}
	for(int i=0; i<len; ++i){
		if(source[i] == ' ') { 
			dest[i] = ' ';
		}else{
			dest[i] = table[source[i]-'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';

		//a = al[3];
		//b = 0;
		//affine(a, b, cin, in, len);
		//puts(cin);
		//strcpy(in, cin);
		strcpy(cin, in);

		o = false;
		tmp = strtok(cin, " ");
		if(strlen(tmp) == 4){
			if(is_true(tmp, &a, &b)){
				raffine(cin, in, a, b, len);
				o = true;
			}
		}
		while(o==false && (tmp = strtok(NULL, " ")) != NULL){
			if(strlen(tmp) == 4 && is_true(tmp, &a, &b)){
				raffine(cin, in, a, b, len);
				o = true;
			}
		}
		
		puts(cin);
	}
	//getchar();getchar();
	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
	int n,ar[] = {1,3,5,7,9,11,15,17,19,21,23,25};
	cin >>n;
	for(int i=0; i<n; i++){
		char word[300] = {0};
		for(int j=0;;j++){
			if(scanf("%c",&word[j]) == EOF){word[j] = 0;break;}
			if(word[j] == '\n'){break;}
		}
		for(int i=0; i<12; i++){
			for(int j=0; j<26; j++){
				for(int k=0; k<(int)strlen(word); k++){
					if(word[k]>='a' && word[k]<='z'){word[k] = (ar[i]*(word[k]-'a')+j)%26+'a';}
				}
				for(int k=0; k<(int)strlen(word); k++){
					if(word[k] == 't' && word[k+1] == 'h' && word[k+2] == 'i' && word[k+3] == 's' && word[k+4] == ' '){cout <<word;break;}
					else if(word[k] == 't' && word[k+1] == 'h' && word[k+2] == 'a' && word[k+3] == 't' && word[k+4] == ' '){cout <<word;break;}
					else if(word[k] == 't' && word[k+1] == 'h' && word[k+2] == 'i' && word[k+3] == 's' && word[k+4] == '\n'){cout <<word;break;}
					else if(word[k] == 't' && word[k+1] == 'h' && word[k+2] == 'a' && word[k+3] == 't' && word[k+4] == '\n'){cout <<word;break;}
				}
			}
		}
	}
	return 0;
}

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

int main(){

	int n, cnt_alph, cnt_word, valid;
	string str, word[51];
	map<int, char> mp;

	for(int i=0; i<26; i++){
		mp.insert(make_pair(i, 'a'+i));
	}

	cin >> n;
	getline(cin, str);

	for(int i=0; i<n; i++){
		cnt_alph = 0;
		cnt_word = 0;
		valid = 0;
	
		getline(cin, str);

		for(int j=0; j<str.length(); j++){
			if(str[j] != ' '){
				word[cnt_word] += str[j];
				cnt_alph++;
			}
			else {
				if(cnt_alph == 4)	cnt_word++;
				else word[cnt_word] = "";
				cnt_alph = 0;
			}
			if(j == str.length() - 1){
				if(cnt_alph == 4)	cnt_word++;
			}
		}
		for(int a=0; valid == 0; a++){
			for(int b=0; valid == 0 && b<26; b++){
				for(int j=0; j<cnt_word; j++){
					if(mp[(a*(word[j][0]-'a')+b)%26] == 't'){
						if(mp[(a*(word[j][1]-'a')+b)%26] == 'h'){
							if((mp[(a*(word[j][2]-'a')+b)%26] == 'a' && word[j][0] == word[j][3]) || (mp[(a*(word[j][2]-'a')+b)%26] == 'i' && mp[(a*(word[j][3]-'a')+b)%26] == 's')){
								for(int k=0; k<str.length(); k++){
									if(str[k] != ' '){
										str[k] = mp[(a*(str[k]-'a')+b)%26];
									}
									cout << str[k];
								}
								cout << endl;
								valid = 1;
							}
						}
					}
				}
			}
		}
	}

	return 0;

}

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

#define rep(a, b, i) for(int i = a; i < b; i++)

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

int main() {
	int n, a, b, c;
	cin >> n;
	cin.ignore();

	string str, res = "";
	for (; n > 0; n--) {
		getline(cin, str);

		rep(1, 40, a) {
			if (a == 2 || a == 13) continue;
			rep(1, 40, b) {
				res = str;
				c = 0;
				rep(0, str.size(), c) {
					if (res[c] == ' ') continue;

					res[c] = ch(a, b, res[c]);
				}
				if (res.find("this") != -1 || res.find("that") != -1) {
					cout << res << endl;
					a = 114514;
					b = 114514;
				}
			}
		}
	}
	return 0;
}

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

int main(void){
	string str;
	int n;
	scanf("%d\n",&n);
	for(int i=0;i<n;i++){
		getline(cin,str);
		for(int j=0;j<26;j++){
			for(int l=0;l<26;l++){
				string str2;
				for(int k=0;k<str.size();k++){
					if(str[k]!=' ')str2+=((str[k]-'a')*l+j)%26+'a';
					if(str[k]==' ')str2+=' ';
				}
				if( str2.find( "this" ) != string::npos || str2.find( "that" ) != string::npos){
					cout << str2 << endl;
					break;
				}
			}
		}
	}
    return 0;
}

C++: #include <iostream>
#include <string>
#include <math.h>
#include <map>
#include <stdio.h>
#include <ctype.h>
#include <algorithm>
#include <stdlib.h>

using namespace std;

int main() {
    string y;
    
    int z[12]={1,3,5,7,9,11,15,17,19,21,23,25};
    
    int affine[12*26][26]={0};
    for(int a=0; a<12; a++){
        for(int b=0; b<26; b++){
            for(int i=0; i<26; i++){
                    affine[a*26+b][(i*z[a]+b)%26]=i;
            }
        }
    }
    
    int temp;
    cin>>temp;
    
    
    
    
    while(getline(cin,y)){
        string x=y;
        
        
        for(int j=0; j<12*26; j++){
            if(x.find("this")!=-1 || x.find("that")!=-1){
                break;
            }
            for(int i=0; i<(int)y.length(); i++){
                if(y[i]==' '){
                    
                }else{
                    x[i]=affine[j][y[i]-'a']+'a';
                }
            }
        }
        
        cout<<x<<endl;
        
    }
    
    
    
    return 0;
}