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

	rep(i, n)
	{
		string str;
		cin.sync();
		getline(cin, str);
		int len = str.size();

		for(int a = 0; ; a++)
		{
			if(a % 2 != 0 && a % 13 != 0)
			{
				rep(b, 25)
				{
					// Ï·Î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:
		;
	}
}

C++: #include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
string change(int a,int b,string str){
    for(int i=0;i<str.size();i++)str[i]=((str[i]-'a')*a+b)%26+'a';
    return str;
}
string out(int a,int b,string str){
    for(int i=0;i<str.size();i++){
        if('a'<=str[i]&&str[i]<='z'){
            for(int j=0;j<26;j++){
                if((j*a+b)%26+'a'==str[i]){
                    str[i]=j+'a';
                    break;
                }
            }
        }
    }
    return str;
}
int main(){
    int N;
    cin>>N;
    for(int i=0;i<N;i++){
        string str;
        if(!i)getchar();
        getline(cin,str);
        for(int j=1;;j++){
            for(int k=0;k<26;k++){
                for(int l=0;l<str.size()-3;l++){
                    if(change(j,k,"that")==str.substr(l,4)){
                        cout<<out(j,k,str)<<endl;
                        goto exit;
                    }
                    if(change(j,k,"this")==str.substr(l,4)){
                        cout<<out(j,k,str)<<endl;
                        goto exit;
                    }
                }
            }
        }
        exit:;
    }
    return 0;
}

C++: #include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int n;
    char ans[257], str[257];
    while(cin >> n){
        cin.ignore();
        rep(i,n){
            cin.getline(str, sizeof(str));
            bool c = false;
            rep(i,26){
                rep(j,26){
                    rep(k,strlen(str)){
                        if(str[k] != ' ')
                            ans[k] = (i * str[k] - 'a' + j) % 26 + 'a';
                        else ans[k] = str[k];
                    }
                    if(strstr(ans, "this") != NULL || strstr(ans, "that") != NULL){
                        c = true;
                    }
                    if(c) break;
                }
                if(c) break;
            }
            ans[strlen(str)] = '\0';
            cout << ans << endl;
        }
    }
}

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;
	std::cin.ignore();
	for(;n--;){
		bool f = true;
		std::string s;
		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>
#define NUM 26
using namespace std;

int gcd(int a, int b){
	if(a%b){
		return gcd(b, a%b);
	}
	return b;
}

int main(){
	int a, y, b, n, i, j, k, fy;
	int ay[257];
	string str, tmpstr;
	cin>>n;cin.ignore();
	for(i=0;i<n;i++){
		getline(cin, str);
		y=0;
		tmpstr = str;
		while(true){
			tmpstr=str;
			while(true){
				y++;
				if(gcd(NUM, y) == 1){
					break;
				}
			}
			for(j=0;j<tmpstr.size();j++){
				if(tmpstr[j] != ' '){
					ay[j] = int(tmpstr[j] - 'a') * y;
				}else{
					ay[j] = -1;
				}
			}
			for(b=0;b<NUM;b++){
				for(j=0;j<tmpstr.size();j++){
					if(ay[j] == -1){
						tmpstr[j] = ' ';
					}else{
						tmpstr[j] = 'a' + ((ay[j] + b) % NUM);
					}
				}
				if(tmpstr.find("this") != string::npos)break;
				if(tmpstr.find("that") != string::npos)break;
				tmpstr = str;
			}
			if(b!=NUM)break;
		}
		cout << tmpstr << endl;
	}
	return 0;
}