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<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<100;i++){
			//if(gcd(i)==1){
				for(int j=0;j<27;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 <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }


int f(int y, int a, int b)
{	return (a * y + b) % 26;	}

int main()
{
	int n;
	cin >> n;
	cin.ignore();

	rep(i, n)
	{
		string str;
		getline(cin, str);

		int len = str.size();

		for(int a = 0; ; a++)
		{
			if(a % 2 != 0 && a % 13 != 0)
			{
				rep(b, 26)
				{
					// Ï·Îe[u
					int v[26];
					rep(y, 26)
						v[f(y, a, b)] = y;
					

					// Ï·
					string con = str;
					rep(in, len)
						if('a' <= con[in] && con[in] <= 'z')
							con[in] = v[con[in] - 'a'] + 'a';


					// Î`FbN
					rep(in, len - 3)
					{
						if(con.substr(in, 4) == "that" || con.substr(in, 4) == "this")
						{
							cout << con << endl;
							goto ng;
						}
					}
				}
			}
		}
ng:
		;
	}
	return 0;
}

C++: #include<iostream>
#include<string>
#include<sstream>
int calc_alpha(const std::string&w, const char*str)
{
	auto distance = [](char from, char to)
	{
		int result = static_cast<int>(to - from);
		return result + (result < 0 ? 26 : 0);
	};
	int dis[3], ratio[3];
	for (int j = 0; j < 3; j++)
	{
		dis[j] = distance(w[j], w[j + 1]);
		int dis2 = distance(str[j], str[j + 1]);
		while (true)
		{
			if (dis[j] % dis2 == 0)
			{
				ratio[j] = dis[j] / dis2;
				break;
			}
			dis[j] += 26;
		}
	}
	return ratio[0] == ratio[1] && ratio[1] == ratio[2] ? ratio[0] : -1;
}
int main()
{
	int n;
	std::cin >> n;
	std::cin.ignore();
	for (int i = 0; i < n; i++)
	{
		std::string str;
		std::getline(std::cin, str);
		std::stringstream ss(str);
		int alpha, beta;
		for (std::string w; ss >> w;)
		{
			if (w.length() == 4)
			{
				alpha = w[0] == w[3] ? calc_alpha(w, "that") : calc_alpha(w, "this");
				if (alpha != -1)
				{
					beta = static_cast<int>(w[0] - 'a' - ('t' - 'a') * alpha % 26);
					break;
				}
			}
		}
		for (auto j : str)
		{
			if (j == ' ')
			{
				std::cout << ' ';
			}
			else
			{
				for (char k = 'a';; k++)
				{
					if (((k - 'a') * alpha + beta) % 26 + 'a' == j)
					{
						std::cout << k;
						break;
					}
				}
			}
		}
		std::cout << std::endl;
	}
	return 0;
}

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

int affine(int word,int A,int B) {
  return (A * word + B) % 26;
}

int main() {
  string str,sentence[256],ans;
  int x[256],afx[256],ansc[256],affans[256],anssize,size,n,alpha,beta,t;
  char convx[256],convans[256],that[5] = {'t','h','a','t','\0'},is[5] = {'t','h','i','s','\0'};
  cin >> n;
  for(int i=0;i<n;i++) {
    t = 0;
    while(cin >> str) {
      sentence[t] = str;
      t++;
      //      cout << sentence[t-1] << endl;
    }
    for(int k=0;k<t;k++) {
      size = sentence[k].size();
      //      cout << size <<endl;
      // size == 4
      if(size == 4) {
	int x[256] = {0},afx[256] = {0};
	char convx[256] = {""};
	for(int i=0;i<size;i++) { //get a word in int[]
	  x[i] = *sentence[k].substr(i,1).c_str() - 97;
	  //  cout << x[i] << endl;
	  //y[i] = x[i] + 97;
	  //cout << y[i] << endl;
	}

	
	for(int ii=0;ii<13;ii++) { //convert a word to affine word
	  for(int j=0;j<26;j++) {
	    for(int m=0;m<size;m++) {
	      if(ii != 6) {
		afx[m] = affine(x[m],2 * ii + 1,j);
		convx[m] = afx[m] +97;
	      }
	    }
	    // cout << convx << endl;
	    if((strcmp(convx,that) == 0) || (strcmp(convx,is) == 0)) {
	      //	      	      cout << "get!get!get!" << endl;
	      alpha = 2 * ii + 1;
	      beta = j;
	      goto NEXT;
	    }
	  }  
	}
     
      }
      // size == 4
    }
  NEXT:
    //    cout << "alpha = " << alpha << " beta = " << beta << endl;
    /*
      for(int m=0;m<t;m++) {
      cout << sentence[m] << endl;
      }
    */
  
    for(int m=0;m<t;m++) { // convert sentence
      ans = sentence[m];
      anssize = ans.size();
      // cout << "OK" << endl;
      for(int j=0;j<anssize;j++) {
	ansc[j] = *ans.substr(j,1).c_str() - 97;
	//	cout << ansc[j] << endl;
	affans[j] = affine(ansc[j],alpha,beta);
	//cout << affans[j] << endl;
	convans[j] = affans[j] +97;
	//	cout << convans[j] << endl;
      }
      convans[anssize] = '\0';
      if(m != t-1)
	cout << convans << " ";
      else
	cout << convans << endl;
    }
    
    
  }
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main(){
	int n;
	cin>>n;
	string s;
	getline(cin,s);
	while(n--){
		getline(cin,s);
		bool h=false;
		rep(i,26){
			string tmp;
			rep(j,26){
				tmp=s;
				rep(k,tmp.size())if(isalpha(tmp[k]))tmp[k]=(i*(tmp[k]-'a')+j)%26+'a';
				rep(k,tmp.size()-3){
					string a=tmp.substr(k,4);
					if(a=="this"||a=="that"){h=true;break;}
				}
				if(h)break;
			}
			if(h){s=tmp;break;}
		}
		cout<<s<<endl;;
	}
}