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 <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <math.h>

#define PREP(i, m, n) for(int i = m; i < n; i++)
#define MREP(i, m, n) for(int i = m - 1; i >= n; i--)

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define X first
#define Y second
#define MP make_pair
#define PB push_back

using namespace std;

map<int, char> number;

bool stringSearch(string input, string *after){
	for(int i = 0; i < 2; i++){
		if(input.find(after[i], 0) != string::npos){
			return true;
		}
	}
	return false;
}

void convert(string *after, string *key, int a, int b){
	for(int i = 0; i < 2; i++){
		for(int j = 0; j < key[i].size(); j++){
			after[i].push_back(number[(a * key[i][j] + b) % 26]);
		}
	}
}

void listConvert(map<char, char> &afterlist, int a, int b){
	for(int i = 0; i < 26; i++){
		afterlist[number[i]] = number[(a * number[i] + b) % 26];
	}
}

bool allSearch(string input, string *key){
	for(int a = 0; a < 26; a++){
		for(int b = 0; b < 26; b++){

			string after[2];
			map<char, char> afterlist;
			convert(after, key, a, b);
			listConvert(afterlist, a, b);

			if(stringSearch(input, after)){
				//文字があったら
				string answer;
				for(int i = 0; i < input.size(); i++){
					if(input[i] != ' '){
						for(map<char, char>::iterator it = afterlist.begin(); it != afterlist.end(); it++){
							if(it->second == input[i]){
								answer.push_back(it->first);
								break;
							}
						}
					}
					else answer.push_back(' ');
				}
				cout << answer << endl;
				return true;
			}

		}
	}
	return false;
}

int main(){
	string key[] = {"this", "that"};
	number[0] = 'a';
	number[1] = 'b';
	number[2] = 'c';
	number[3] = 'd';
	number[4] = 'e';
	number[5] = 'f';
	number[6] = 'g';
	number[7] = 'h';
	number[8] = 'i';
	number[9] = 'j';
	number[10] = 'k';
	number[11] = 'l';
	number[12] = 'm';
	number[13] = 'n';
	number[14] = 'o';
	number[15] = 'p';
	number[16] = 'q';
	number[17] = 'r';
	number[18] = 's';
	number[19] = 't';
	number[20] = 'u';
	number[21] = 'v';
	number[22] = 'w';
	number[23] = 'x';
	number[24] = 'y';
	number[25] = 'z';
	
	int n = 0;
	cin >> n;
	while(n--){
		cin.ignore();
		string input;
		getline(cin, input);
		allSearch(input, key);
	}

	return 0;
}

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

using namespace std;

string conv(int a, int b, string str)
{
	string line=str;
	for(int i=0;i<line.length();i++)
	{
		if('a'<=line.at(i)&&line.at(i)<='z')
		{
			line.at(i)-='a';
			for(int y=0;y<26;y++)
			{
				if((a*y+b)%26==line.at(i))
				{
					line.at(i)=y+'a';
					break;
				}
			}
		}
	}
	return line;
}

string solve(string line)
{
	for(int b=0;b<26;b++)
	{
		for(int a=1;a<100;a++)
		{
			if(a%2!=0&&a%13!=0)
			{
				string ans=conv(a,b,line);
				if(ans.find("that")!=string::npos||ans.find("this")!=string::npos)
				{
					return ans;
				}
			}
		}
	}
	return line;
}

int main(void)
{
	int n;
	string line;
	getline(cin,line);
	stringstream ss(line);
	ss>>n;
	for(int i=0;i<n;i++)
	{
		getline(cin,line);
		cout<<solve(line)<<endl;
	}
}

C++: #include<iostream>
#include<vector>
#include<map>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

bool func(int a,int b,int y,int fy){
	return fy==(a*y+b)%26;
}

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

map<char,int> mp;
map<int,char> rever;

int main(){
	rep(i,26){
		int ch=(int)'a';
		mp[(char)(ch+i)]=i;
		rever[i]=(char)(ch+i);
	}
	int n;
	cin>>n;
	rep(l,n){
		string s,temp="";
		if(l==0)cin.ignore();
		getline(cin,s);
		vector<string> vec;
		vector<int> flg;
		rep(i,s.size()+1){
			if(s[i]==' ' || i==s.size()){
				if(temp.size()==4)flg.push_back(vec.size());
				vec.push_back(temp);
				temp="";
			}else{
				temp+=s[i];
			}
		}
		int alpha,beta;
		rep(i,flg.size()){
			alpha=beta=-1;
			rep(a,27){
				rep(b,27){
					bool check[3];
					check[0]=func(a,b,mp['t'],mp[vec[flg[i]][0]]);
					check[1]=func(a,b,mp['h'],mp[vec[flg[i]][1]]);
					check[2]=func(a,b,mp['a'],mp[vec[flg[i]][2]]) || func(a,b,mp['i'],mp[vec[flg[i]][2]]);
					if(check[0] && check[1] && check[2]){
						alpha=a;
						beta=b;
						break;
					}
				}
				if(alpha!=-1 || beta!=-1)break;
			}
			if(alpha!=-1 || beta!=-1)break;
		}
		string ans="";
		int alt;
		rep(i,vec.size()){
			rep(j,vec[i].size()){
				alt=mp[vec[i][j]];
				rep(i,26){
					if(func(alpha,beta,i)==alt){
						alt=i;
						break;
					}
				}
				ans+=rever[alt];
			}
			if(i!=vec.size()-1)ans+=" ";
		}
		cout<<ans<<endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
void solve() {
	string s; getline(cin, s);
	for1(a, 25) {
		if (a % 2 == 0 || a % 13 == 0)continue;
		for0(b, 26) {
			string s1;
			for (char ch : s)if (ch != ' ')s1 += 'a' + ((ch - 'a') * a + b) % 26; else s1 += ' ';
			if (s1.substr(0, 5) == "this " || s1.substr(0, 5) == "that " || s1.find(" this ") < s.size() || s1.find(" that ") < s.size() || s1.substr(s1.size() - 5, 5) == " this" || s1.substr(s1.size() - 5, 5) == " that") {
				cout << s1 << endl;
				return;
			}
		}
	}
}
signed main() {
	string n; getline(cin, n);
	for0(i, stoi(n))solve();
}

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);
		string en = "abcdefghijklmnopqrstuvwxyz";
		string ans = "";
		int i = 0;
		while(++i){
			if(i%2 == 0 || i%13 == 0)continue;
			rep(j,26){
				string sub;
				rep(k,str.size()){
					if(str[k] == ' ')sub += " ";
					else sub += en[((i*(str[k]-'a')+j) % MOD)];
				}
				rep(k,sub.size()-4){
					if(sub[k] == 't'&&sub[k+1] == 'h'&&sub[k+2] == 'i'&&sub[k+3] == 's'){
						ans = sub;
						goto end;
					}
					if(sub[k] == 't'&&sub[k+1] == 'h'&&sub[k+2] == 'a'&&sub[k+3] == 't'){
						ans = sub;
						goto end;
					}
				}
			}
		}
		end:;
		cout << ans << endl;
	}
	return 0;
}