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<ctime>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<numeric>
using namespace std;
const int dx[]={1,0,-1,0};
const int dy[]={0,1,0,-1};
#define INF 1e+8
#define EPS 1e-7
#define PB push_back
#define fi first
#define se second
#define ll long long
#define MOD 26
#define reps(i,j,k) for(int i = (j); i < (k); i++)
#define rep(i,j) reps(i,0,j)
typedef pair<int,int> Pii;
typedef vector<int> vi;
int main(){
	int n;
	scanf("%d",&n);
	while(n--){
		getchar();
		string str;
		getline(cin,str);
		vector < string > target;
		rep(i,str.size()-3){
			string sub(str,i,4);
			if(i == 0){
				if(str[4] == ' ' || str[4] == '\0'){
					if(str[0] != ' '&&str[1] != ' '&&str[2] != ' '&&str[3] != ' '){
						target.PB(sub);
					}
				}
			}
			else if(i == str.size()-4){
				if(str[str.size()-5] == ' '){
					if(str[i] != ' '&&str[i+1] != ' '&&str[i+2] != ' '&&str[i+3] != ' '){
						target.PB(sub);
					}
				}
			}
			else{
				if(str[i-1] == ' ' && str[i+4] == ' '){
					if(str[i] != ' '&&str[i+1] != ' '&&str[i+2] != ' '&&str[i+3] != ' '){
						target.PB(sub);
					}
				}
			}
		}
		string en = "abcdefghijklmnopqrstuvwxyz";
		string ans = "";
		int i = 0;
		int alpha;
		int beta;
		while(++i){
			if(i%2 == 0 || i%13 == 0)continue;
			rep(j,26){
				rep(k,target.size()){
					string sub;
					rep(l,4){
						sub += en[((i*(target[k][l]-'a')+j) % MOD)];
					}
					if(sub == "this" || sub == "that"){
						alpha = i;
						beta = j;
						goto end;
					}
				}
			}
		}
		end:;
		rep(i,str.size()){
			if(str[i] == ' ')ans += " ";
			else ans += en[((alpha*(str[i]-'a')+beta) % MOD)];
		}
		cout << ans << endl;
	}
	return 0;
}

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;
        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>
#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 <cstdio>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

string func(string s){
	for(int a = 1;;a++){
		for(int b = 0;b < 26;b++){
			string t = s;
			for(int i = 0;i < s.size();i++){
				if(t[i] != ' '){
					t[i] = (a*(t[i]-'a') + b) % 26 + 'a';
				}
			}
			if(t.find("this") != -1 || t.find("that") != -1)return t;
		}
	}
}

int main(){
	int n;cin >> n;
	string s;
	getline(cin, s);
	while(n--){
		getline(cin, s);
		cout << func(s) << endl;
	}
	return 0;
}
/*
1
y eazqyp pnop pngtg ye obmpngt xmybp mr lygw
*/

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

string convert(int a, int b, string str) {
    for (int i = 0; i < (int)str.length(); ++i) {
        if (str[i] != ' ')
            str[i] = char((a * (str[i] - 'a') + b) % 26 + 'a');
    }
    return str;
}


int main(void) {
    int n;
    string str;
    cin >> n;
    getline(cin, str);
    for (int i = 0; i < n; ++i) {
        bool flag = false;
        string str;
        getline(cin, str);
        for (int a = 0; a < 26; ++a) {
            for(int b = 0; b < 26; ++b) {
                string str2;
                stringstream ss;
                ss << convert(a, b, str);
                while (!ss.eof()) {
                    ss >> str2;
                    if (str2 == "this" || str2 == "that") {
                        cout << convert(a, b, str) << endl;
                        flag = true;
                        break;
                    }
                }
                if (flag)
                    break;
            }
            if (flag)
                break;
        }
    }
    return 0;
}