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<vector>
#include<sstream>
using namespace std;
int main(){
    string thth[2]={"this","that"};
    string ths[2][26][26];
    for(int i=0;i<2;i++){
        for(int ia=0;ia<26;ia++){
            for(int ib=0;ib<26;ib++){
                ths[i][ia][ib]="    ";
            }
        }
    }
    for(int i=0;i<4;i++){
        for(int j=0;j<2;j++){
            thth[j][i]-='a';
        }
    }
    for(int ia=0;ia<26;ia++){
        for(int ib=0;ib<26;ib++){
            for(int j=0;j<4;j++){
                for(int k=0;k<2;k++){
                    ths[k][ia][ib][j]=(thth[k][j]*ia+ib)%26;
                }
            }
        }
    }
    int n;
    cin>>n;
    string line,ins;
    getline(cin,line);
    for(int ii=0;ii<n;ii++){
        int aa=0,bb=0;
        vector<string> strs;
        getline(cin,line);
        stringstream ss(line);
        while(ss>>ins){
            strs.push_back(ins);
        }
        for(int i=0;i<strs.size();i++){
            for(int j=0;j<strs[i].size();j++){
                strs[i][j]-='a';
            }
        }
        for(int i=0;i<strs.size();i++){
            if(strs[i].size()==4){
                for(int ia=0;ia<26;ia++){
                    for(int ib=0;ib<26;ib++){
                        for(int j=0;j<2;j++){
                            if(strs[i]==ths[j][ia][ib]){
                                aa=ia;
                                bb=ib;
                                goto TO;
                            }
                        }
                    }
                }
            }
        }
TO:
        char cry[26];
        for(int i=0;i<26;i++){
            cry[(i*aa+bb)%26]=i;
        }
        for(int i=0;i<strs.size();i++){
            for(int j=0;j<strs[i].size();j++){
                strs[i][j]=cry[strs[i][j]]+'a';
            }
        }
        for(int i=0;i<strs.size()-1;i++){
            cout<<strs[i]<<' ';
        }
        cout<<strs[strs.size()-1]<<endl;
    }
}

C++: #include <iostream>
#include <vector>

using namespace std;
const vector<int> v{1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25};

int main() {
    string n;
    getline(cin, n);

    for (int count = 0; count < stoi(n); count++) {
        string s;
        getline(cin, s);

        bool finished = false;
        for (auto alpha:v) {
            vector<int> conv(26);
            for (int beta = 0; !finished && beta < 26; beta++) {
                for (int c = 0; c < 26; c++) {
                    int x = alpha * c + beta;
                    conv[x % 26] = c;
                }

                string after = s;
                for (int i = 0; i < s.size(); i++) {
                    if (after[i] == ' ')continue;
                    after[i] = conv[after[i] - 'a'] + 'a';
                }

                bool found = false;
                for (int i = 0; i < after.size() - 3; i++) {
                    string now = after.substr(i, 4);
                    if (now == "that" || now == "this")found = true;
                }
                if (found) {
                    cout << after << endl;
                    finished = true;
                }
            }
        }
    }
    return 0;
}

C++: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	int i,n;
	scanf("%d\n",&n);
	for(i=0;i<n;i++){
		string str;
		char s[300];
		gets(s);
		str=s;
//cout<<str<<endl;
		int a,b;
		for(a=1;a<26;a+=2){
			if(a==13)continue;
			for(b=0;b<26;b++){
				string st="";
				int j;
				for(j=0;j<str.size();j++){
					if(isalpha(str[j])){
						st+=((str[j]-'a')*a+b)%26+'a';
					}else{
						st+=str[j];
					}
				}
//if(st[0]=='i')cout<<st<<endl;
				string::size_type index1=st.find("that");
				string::size_type index2=st.find("this");
				if(index1!=string::npos||index2!=string::npos){
					cout<<st<<endl;
					goto end;
				}
			}
		}
		end:;
	}
	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 dis1[3], ratio[3];
	for (int j = 0; j < 3; j++)
	{
		dis1[j] = distance(w[j], w[j + 1]);
		int dis2 = distance(str[j], str[j + 1]);
		while (true)
		{
			if (dis1[j] % dis2 == 0)
			{
				ratio[j] = dis1[j] / dis2;
				break;
			}
			dis1[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;
				}
			}
		}
		char deciphered[26];
		for (char j = 'a'; j <= 'z'; j++)
		{
			char ciphered = ((j - 'a') * alpha + beta) % 26 + 'a';
			deciphered[ciphered - 'a'] = j;
		}
		for (auto j : str)
		{
			std::cout << (j == ' ' ? ' ' : deciphered[j - 'a']);
		}
		std::cout << std::endl;
	}
	return 0;
}

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

bool ok(int a,int b){
	int ta[26];
	fill(ta,ta+26,0);
	for(int i=0;i<26;i++){
		ta[(a*i+b)%26]++;
	}
	for(int i=0;i<26;i++)if(ta[i]>=2)return 0;
	return 1;
}
char ango(char n,int a,int b){
	int y=n-'0';
	int next=(y*a+b)%26;
	char tmp='a';
	for(int i=0;i<next;i++)tmp++;
	return tmp;
}
int main(){
	int ccc;
	cin>>ccc;
	cin.ignore();
	for(int cc=0;cc<ccc;cc++){
		string tn,n;
		getline(cin,n);
		for(int a=0;a<=26;a++){
			for(int b=0;b<=26;b++){
				tn=n;
				if(ok(a,b)){
					for(int i=0;i<(int)tn.size();i++){
						if(tn[i]!=' ')tn[i]=ango(tn[i],a,b);
					}
					bool f=0;
					for(int i=0;i<(int)tn.size()-4;i++){
						string tmp="aaaa";
						for(int j=0;j<4;j++)tmp[j]=tn[i+j];
						if(tmp=="this"||tmp=="that"){cout<<tn<<endl;goto next;}
					}
				}
			}
		}
		
		next:;
	}
	
	return 0;
}