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;

int main()
{
	string str, w1, w2;
	int a, b, c, n;
	int da[26];
	cin>>n;
	while(n>0){
		getline(cin, str);
		if( str.size()==0) continue;
		for(a=1;a<26;a+=2){
			if(a==13) continue;
			for(b=0;b<26;b++){
				w1 = "that"; w2 = "this";
				for(c=0;c<4;c++){
					w1[c] = (char) ('a' + ((a*(w1[c]-'a')+b) % 26));
					w2[c] = (char) ( 'a' + ((a*(w2[c]-'a')+b) % 26));
				}
				// 見つかればbreak
				if( str.find(w1) != string::npos || str.find(w2) != string::npos) break;
			}
			if(b<26) break; // 上記のif文が実行されたのであればb<26が成り立つ
		}
		
		for(c=0;c<26;c++){
			da[ (a*c+b) % 26 ] = c;
		}
		for(c=0;c<str.size();c++){
			if(str[c] == ' ') cout <<' ';
			else cout << (char) ('a' + da[ str[c] - 'a'] );
		}
		cout<<endl;
		n--;
	}
	return 0;
}

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


#define MAX_STR 257
#define ALFA_NUM 26

using namespace std;

int gcd(int);

int main(){

	int n;
	char str[MAX_STR],fstr[MAX_STR];
	bool flag;
	
	cin>>n;
	
	
	while(n--){
		flag=true;
		//改行がバッファに残っているので捨てる
		fflush(stdin);
				
		fgets(str,sizeof(str),stdin);
		
		
		for(int i=0;i<1000;i++){
			if(gcd(i)==1){
				for(int j=0;j<30;j++){
				
					memset(fstr,'\0',sizeof(fstr));
					
					for(int k=0;str[k]!='\0' && k<sizeof(str);k++){
						
						if(str[k]!='\n' && str[k]!=' '){
							fstr[k]=((i*(str[k]-'a')+j)%ALFA_NUM)+'a';
						}
						else if(str[k]!='\n'){
							fstr[k]=str[k];
						}					
					}
					
					if(strstr(fstr,"that")!=NULL||strstr(fstr,"this")!=NULL){
						printf("%s\n",fstr);
						goto Z;
					}
				}
			}
		}
		Z:;
	}
}

int gcd(int n){
	int temp,m;
	m=ALFA_NUM;
	if(n>m){
		temp=n;
		n=m;
		m=temp;
	}
	while(1){
		if(n==0){
			return m;
		}
		temp=n;
		n=m%n;
		m=temp;
	}
}

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=0,b=-1;
		while(s.find("that")==string::npos && s.find("this")== string::npos){
			a++;
			b++;
			while(a%2==0||a%13==0)a++;
			if(b==26)b=0;
			makelist(a,b);
			s=translate(tmp);
			//cout<<s<<endl;
		}
		cout<<s<<endl;
	}
}

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

int main(){
	int n;
	char str[257] = {}, str_c[257], len;
	cin >> n;
	getchar();
	for (int m = 0; m < n; m++){
		gets(str);
		len = strlen(str);
		//printf("%d\n", len);
		for (int i = 1; i < 26; i++){
			if (i % 2 == 0 || i % 13 == 0) continue;
			for (int j = 0; j < 26; j++){
				for (int k = 0; k <= len; k++){
					if (isalpha(str[k])){
						str[k] -= 'a';
						str_c[k] = (str[k] * i + j) % 26 + 'a';
						str[k] += 'a';
					}
					else{
						str_c[k] = str[k];
					}
				}
				if (strstr(str_c, "this") || strstr(str_c, "that")){
					printf("%s\n", str_c);
					return 0;
				}
			}
		}
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define pb push_back
#define mp make_pair
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

/*
αとβについて全探索を掛ける
αとβの組ごとにアルファベットの置換表を作る
与えられた文字列を置換表を下に下の文章に直す
*/

int n;
string inp;
map<char, char> m;

int main()
{
	cin >> n;
	getline(cin, inp);

	while (n--)
	{
		getline(cin, inp);
		//cout << inp << endl;
		bool exit = false;

		for (int alpha=0; alpha<=100; alpha++)
		{
			for (int beta=0; beta<=100; beta++)
			{
				m.clear();
				
				m[' '] = ' ';
				for (int pre='a'; pre<='z'; pre++)
				{
					int y = pre - 'a';
					int fy = (alpha * y + beta) % 26;
					char post = fy + 'a';
					m[post] = pre;
				}
	
				//暗号文を原文に置換する
				string genbun = "";
				for (int i=0; i<inp.length(); i++)
				{
					genbun += m[inp[i]];
				}

				if ((genbun.find("that", 0) != string::npos) || genbun.find("this", 0) != string::npos)
				{
					exit = true;
					cout << genbun << endl;
					break;
				}
			}

			if (exit) break;
		}
	}
	
	return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	int n,i,j,k;string s,t;cin>>n;
	while(n--){getline(cin,s);t=s;
		for(i=0;i<30;i++)for(j=0;j<30;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=j=30;
		}cout<<t<<endl;
	}return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
using namespace std;
	
int F(int alpha,int beta,int ch){
	return (alpha*ch+beta)%26;
}
int gcd(int a,int b){
	return b==0?a:gcd(b,a%b);
}
int main(){
	int n;
	string in,s,ans;
	cin>>n;
	getline(cin,in);
	while(n--){
		getline(cin,in);
		for(int i=1;i<26;i++){
			if(gcd(26,i)!=1)continue;
			for(int j=0;j<26;j++){
				int table[26];
				fill(table,table+26,-1);
				for(int k=0;k<26;k++){
					table[F(i,j,k)] = k;
				}
				if(count(table,table+26,-1))continue;
				s.resize(in.size());
				for(int k=0;k<in.size();k++){
					if(in[k]==' ')s[k]=' ';
					else s[k] = table[in[k]-'a']+'a';
				}
				if(s.find("that",0)!=string::npos
					|| s.find("this",0)!=string::npos){
					cout<<s;
					return 0;
				}
			}
		}
	}
	return 0;
}

C++: #include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
#include<map>
#include<cmath>
#include<complex>
using namespace std;

typedef complex<double> P;

#define X real()
#define Y imag()
typedef int kz;

kz gcd(kz a,kz b) { if(b==0) return a; else gcd(b,a%b); }

int main(){
    int mod=1000000007;
    int n,len,x,y;
    char s[260];
    scanf("%d",&n);
    for (int i=0;i<n;++i) {
        fgets(s,260,stdin);
        len=strlen(s)-1;
        for (int a=0;a<26;++a) {
            if (gcd(a,26)!=1) continue;
            for (int b=0;b<26;++b) {
                char chk[len];
                for (int c=0;c<len;++c) {
                    if (isalpha(s[c])) {
                        chk[c]=((((s[c]-'a')*a+b)%26)+'a');
                        if (!strncmp(&chk[c],"this",4) || !strncmp(&chk[c],"that",4)) {
                            x=a;
                            y=b;
                            break;
                        }
                    }
                }
            }
        }
        for (int p=0;p<len;++p) {
            printf("%c\n",(((s[p]-'a')*x+y)%26+'a'));
        }
        printf("\n");
    }
    return 0;
}