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>

using namespace std;

int gcd(int x,int y){
  if(y == 0)return x;
  return gcd(y,x%y);
}

int lcm(int x,int y){
  return (x*y)/gcd(x,y);
}

string affine(string s,int a,int b){
  string news;
  news.clear();
  for(int i=0;i<s.length();i++){
    if(!('a'<= s[i] && s[i]<='z') ){
      news+=s[i];
      continue;
    }
    int y = s[i]-'a';
    news+= (char)((a*y+b)%26+'a');
  }
  
  return news;
}


int main(){

  int N;
  string s;
  cin >> N;
  cin.ignore();
  while(N-- > 0){
    getline(cin,s,'\n');
    bool fin = false;
    for(int a=0;a<=50;a++){
      if(gcd(a,26) == 1){
	for(int b=0;b<26;b++){
	  string Ns = affine(s,a,b);	  
	  if(Ns.find("that") != string::npos || Ns.find("this") != string::npos){
	    cout << Ns << endl;
	    fin = true;
	    break;
	  }
	}

	}
	if(fin)break;
    }
    if(!fin)cout << s << endl;


  }
  return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	int n,i,j,k;string s,t;cin>>n;
	getline(cin,s);
	while(n--){getline(cin,s);t=s;
		for(i=0;i<99;i++)for(j=0;j<26;j++){
			for(k=0;k<s.size();k++)t[k]=s[k]-32?97+(i*s[k]+j)%26:32;
			if(t.find("this")+1||t.find("that")+1)i=99;
		}cout<<t<<endl;
	}return 0;
}

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

string dec(string s){
string s1="this";
string s2="that";
	for(int a=0;a<26;a++){
		for(int b=0;b<26;b++){
			string s3=s1;string s4=s2;int fd3=-1,fd4=-1;
			for(int c=0;c<4;c++){
				s3[c]=(a*(s3[c]-'a')+b)%26+'a';
				s4[c]=(a*(s4[c]-'a')+b)%26+'a';
			}//c
			fd3=s.find(s3);fd4=s.find(s4);
			if( fd3>=0 || fd4>=0 ) {
			int N=0;int tp=0;
			for(int d=0;d<s.length();d++){
				if(s[d]==' ')continue;
					for(N=0;N<=26;N++){
						if( (s[d]-'a'+11*N-b)>=0 && (s[d]-'a'+26*N-b)%a==0 ){
						tp=N;
						s[d]='a'+(s[d]-'a'+26*tp-b)/a;
						break;
						}
					}
			}
			break;
		}
		}
	}
	
return s;
}


int main(void){
int num;

cin>>num;
string s;
	getline(cin,s);//read num->\n
for(int i=0;i<num;i++){
	getline(cin,s);
	cout<<dec(s)<<endl;
}
	return 0;
}

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

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

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 = 1013;
		//b = 43289;
		//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 <string>
#include <iostream>
using namespace std;

int main(void) {
	int n;
	cin >> n;
	string input;
	while(getline(cin, input)) {
		bool flag = true;
		for(int a = 1; a <= 26 && flag; a++) {
			if(26 % a == 0)
				continue;
			for(int b = 1; b <= 26; b++) {
				string str = input;
				int l = str.size();
				for(int i = 0; i < l; i++) {
					if(str[i] >= 'a' && str[i] <= 'z')
						str[i] = (a * (str[i] - 'a') + b) % 26 + 'a';
				}
				if(str.find("this") != string::npos || str.find("that") != string::npos) {
					flag = false;
					cout << str << '\n';
				}
			}
		}
	}
}

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

string solve(string s){
	string t;
	for(int a = 1; ; ++a)
	for(int b = 0; b < 26; ++b){
		t = s;
		for(int i = 0; i < t.size(); ++i){
			if(t[i] != ' '){
				t[i] = (a * (t[i] - 'a') + b) % 26 + 'a';
			}
		}
		if(t.find("this") != string::npos || t.find("that") != string::npos){
			return t;
		}
	}
}

int main(){
	int n;
	cin >> n;
	cin.get();
	string s;
	for(int i = 0; i < n; ++i){
		getline(cin, s);
		cout << solve(s) << '\n';
	}
}