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<algorithm>

int extgcd(int a, int b, int& x, int& y){
	int d = a;
	if(b != 0){
		d = extgcd(b, a%b, y, x);
		y -= (a/b) * x;
	}else{
		x = 1; y = 0;
	}
	return d;
}

int mod_inverse(int a, int m){
	int x, y;
	extgcd(a, m, x, y);
	return (m + x % m) % m;
}

int main(){
	int n;
	std::cin >> n;
	for(;n--;){
		bool f = true;
		std::string s;
		std::cin.ignore();
		std::getline(std::cin, s);
		for(int a=1;a<26&&f;a++){
			if(26 % a == 0)continue; //素ではない
			for(int b=0;b<26&&f;b++){
				std::string new_s = s;
				int inverse_a = mod_inverse(a, 26);
				std::transform(new_s.begin(), new_s.end(), new_s.begin(),
											 [inverse_a, b](char c){
												 if(c == ' ')return c;
												 int x = c - 'a';
												 int new_x = inverse_a * (x-b) % 26;
												 new_x = new_x<0?new_x+26:new_x;//C++だと負の値に対する剰余が負になるので26加えて正にする
												 return static_cast<char>(new_x + 'a');
											 });
				if(new_s.find("this") != std::string::npos ||
					 new_s.find("that") != std::string::npos){
					std::cout << new_s << std::endl;
					f = false;
				}
			}
		}
	}
}

C++: #include<iostream>
#include<string>
#include<algorithm>
using namespace std;
	
char F(int alpha,int beta,char c){
	return 'a'+(alpha*(c-'a')+beta)%26;
}
int gcd(int a,int b){
	return b==0?a:gcd(5,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++){
				s.resize(in.size());
				for(int k=0;k<in.size();k++){
					if(in[k]==' ')s[k]=' ';
					else s[k]=F(i,j,in[k]);
				}
				if(s.find("that",0)!=string::npos
					|| s.find("this",0)!=string::npos){
					cout<<s<<endl;
					return 0;
				}
			}
		}
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<complex>
#include<map>

#define f first
#define s second

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define EPS (1e-10)
using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

int  mp[26][26][26];
bool ok[26][26];

void init(){
  REP(a,26){
    REP(b,26){
      bool tmp[26] = {false};
      ok[a][b] = true;
      REP(c,26){
	int f = (a*c+b)%26;
	if(tmp[f]){
	  ok[a][b] = false;
	  break;
	}
	mp[a][b][c] = f;
      }
    }
  }
}

int main(){
  int n;
  string str;
  getline(cin, str);
  n = atoi(str.c_str());
  init();
  while(n --> 0){
    int len;
    getline(cin, str);
    len = str.size();
    REP(a,26) REP(b,26) if(ok[a][b]){
      string dec = str;
      REP(i,len)
	if(isalpha(dec[i]))
	  dec[i] = mp[a][b][dec[i]-'a'] + 'a';
      //cout << "decoded: " << dec << endl;
      if(dec.find("this") != string::npos ||
	 dec.find("that") != string::npos){
	cout << dec << endl;
	goto end;
      }
    }
  end:;
  }
  return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
using namespace std;
int gcd(int s)
{
	int i;
	for(i=2;i<=26;i++)
	{
		if(s%i==0&&26%i==0)break;
	}
	if(i<=26)return 1;
	else return 0;
}
int main()
{
	int n,a,b,c,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=0;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"))
				{
					printf("%s\n",tmp);
					a=26;
					break;
				}
			}
		}
	}
	return 0;
}

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

int main(){
	char ango[24*26][26],ss[300],sso[300];
	int i,j,k,n,a,b;
	i=0;
	for(a=1;a<26;a++){
		if(a%2==0 || a%13==0)continue;
		for(b=0;b<26;b++){
			for(j=0;j<26;j++){
				ango[i][(a*j+b)%26]=j;
			}
			++i;
		}
	}
	scanf(" %d ",&n);
	
	for(i=0;i<n;i++){
		memset(ss,0,sizeof(ss));
		fgets(ss,sizeof(ss),stdin);
		
		for(j=0;;j++){
			for(k=0;k<300;k++){
				if(ss[k]=='\0')break;
				if(ss[k]=='\n')ss[k]='\0';
				if('a'<=ss[k] && ss[k]<='z'){
					sso[k]='a'+ango[j][ss[k]-'a'];
					continue;
				}
				sso[k]=ss[k];
			}
			if(strstr(sso,"this")!=NULL || strstr(sso,"that")!=NULL)break;
		}
		
		printf("%s\n",sso);
	}
	return 0;
}

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

using namespace std;


//??¨??¬??????a,b????????????????????????????????¢??°
bool judge(int a, int b){
	int checkTable[26];
	for(int i=0;i<26;i++)checkTable[i] = 0;
	for(int i=0;i < 26;i++){
		if(checkTable[(a*i+b)%26] == 0){
			checkTable[(a*i+b)%26] = 1;
		}else{
			return false;
		}
	}
	return true;
}


int main(){
	int n,length,a,b;
	char buf[300],convert[26],s1,s2,s3,s4;
	bool FLG;

	scanf("%d",&n);
	getchar();
	for(int i=0;i<n;i++){
		fgets(buf,300,stdin);
		length = 0;
		FLG = false;
		//??????4?????????????????¢??????a,b?????????????????????
		for(int k=0;buf[k] != '\0';k++){
			if(buf[k] == ' '){
				if(length == 4){

					s1 = buf[k-4] - 97;
					s2 = buf[k-3] - 97;
					s3 = buf[k-2] - 97;
					s4 = buf[k-1] - 97;

					//this??§??¨??¬
					if(s1 > s4){
						a = s1 - s4;
					}else{
						a = (s1 + 26) -s4;
					}
					b = -1;
					for(int p=0;p<26;p++){
						if((19*a+p)%26==s1){
							b = p;
							if(judge(a,b)){
								FLG = true;
								break;
							}
						}
					}
					if(FLG){
						break;
					}


					//that??§??¨??¬
					a = -1;
					b = s3;
					for(int p=0;p<26;p++){
						if((19*p+b)%26==s1){
							a = p;
							if(judge(a,b)){
								FLG = true;
								break;
							}
						}
					}
					if(FLG){
						break;
					}
				}
				length = 0;
			}else if(buf[k+1] == '\0'){
				length++;
				if(length == 4){

					s1 = buf[k-3] - 97;
					s2 = buf[k-2] - 97;
					s3 = buf[k-1] - 97;
					s4 = buf[k] - 97;

					//this??§??¨??¬
					if(s1 > s4){
						a = s1 - s4;
					}else{
						a = (s1 + 26) -s4;
					}
					b = -1;
					for(int p=0;p<26;p++){
						if((19*a+p)%26==s1){
							b = p;
							if(judge(a,b)){
								FLG = true;
								break;
							}
						}
					}
					if(FLG){
						break;
					}


					//that??§??¨??¬
					a = -1;
					b = s3;
					for(int p=0;p<26;p++){
						if((19*p+b)%26==s1){
							a = p;
							if(judge(a,b)){
								FLG = true;
								break;
							}
						}
					}
					if(FLG){
						break;
					}
				}
				length = 0;
			}else{
				length++;
			}
		}

		//????????¨?????????
		for(int k = 0; k < 26;k++)convert[(a*k+b)%26] = k;

		for(int k=0;buf[k] != '\0';k++){
			if(buf[k]>=97 && buf[k] <= 122){
				buf[k] = convert[buf[k]-97]+97;
			}
		}
		printf("%s\n",buf);
	}

    return 0;
}