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 <bits/stdc++.h>

#define SIZE 300005
#define MOD 1000000007LL
#define INF INT_MAX / 3
#define LLINF 1LL << 60
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define FORALL(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FOREACH(i,c) for(auto (i) : (c))
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef valarray<int> Array;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cout<<a[i];if(i==a.size()-1)cout<<endl;else cout<<" ";}}
int gcd(int a,int b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
int lcm(int a,int b){return a==0||b==0?0:a*b/gcd(a,b);}


vector<string> split(const string &str, char delim)
{
  istringstream iss(str); string tmp; vector<string> res;
  while(getline(iss, tmp, delim)) res.push_back(tmp);
  return res;
}

void solve(string s)
{
  vector<string> words = split(s,0x20);
  for(auto t : words)
  {
    if(t.size() != 4) continue;
    else
    {
      FOR(a,1,25)
      {
        if(gcd(a,26)!=1) continue;
        FOR(b,0,25)
        {
          string tmp = t;
          REP(j,4) tmp[j] = 'a'+((a*(tmp[j]-'a')+b)%26);
          if(tmp == "this" || tmp == "that")
          {
            REP(i,s.size()) if(s[i] != 0x20)s[i] = 'a'+((a*(s[i]-'a')+b)%26);
            printf("%s\n",s.c_str());
            return;
          }
        }
      }
    }
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n; cin.ignore();
  REP(i,n)
  {
    string s;
    getline(cin,s);
    solve(s);
  }
  return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
using namespace std;
	
int F(int alpha,int beta,int ch){
	return (alpha*ch+beta)%26;
}
int gcd(int a,int b){
	return b==0?a:gcd(b,a%b);
}
int main(){
	int n;
	string in,s,ans;
	cin>>n;
	getline(cin,in);
	while(n--){
		getline(cin,in);
		for(int i=1;i<26;i++){
			if(gcd(26,i)!=1)continue;
			for(int j=0;j<26;j++){
				int table[26];
				for(int k=0;k<26;k++){
					table[F(i,j,k)] = k;
				}
				s.resize(in.size());
				for(int k=0;k<in.size();k++){
					if(in[k]==' ')s[k]=' ';
					else s[k] = table[in[k]-'a']+'a';
				}
				if(s.find("that",0)!=string::npos
					|| s.find("this",0)!=string::npos){
					cout<<s;
					return 0;
				}
			}
		}
	}
	return 0;
}

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

int main(void) {
	int n;
	cin >> n;
	string input;
	getline(cin, input);
	while(n--) {
		getline(cin, input);
		bool flag = true;
		for(int a = 1; a <= 26 && flag; a++) {
			if(26 % a == 0)
				continue;
			for(int b = 0; b < 26; b++) {
				string str = input;
				int l = str.size();
				for(int i = 0; i < l; i++) {
					if(str[i] >= 'a' && str[i] <= 'z')
						str[i] = (a * (str[i] - 'a') + b) % 26 + 'a';
				}
				if(str.find("this") != string::npos || str.find("that") != string::npos) {
					flag = false;
					cout << str << '\n';
				}
			}
		}
	}
}

C++: #include <stdio.h>
#include <string.h>

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

int change(char str[257],int a,int b){
	int i;
	for(i = 0;str[i] != '\0';i++){
		str[i] = str[i] == ' ' ? ' ' : (a*(str[i]-'a')+b)%26+'a';
	}
	for(i = 0;str[i+3] != '\0';i++){
		if(!strncmp(str+i,"that",4) || !strncmp(str+i,"this",4)){
			return 1;
		}
	}
	
	return 0;
}

int main(void) {
	int i,n,a,b;
	char str[257],str2[257];
	
	scanf("%d",&n);
	gets(str);
	for(i = 0;i < n;i++){
		gets(str);
		for(a = 1;a < 512;a+=2){
			for(b = 1;b < 512;b++){
				if(gcd(a,26) != 1) continue;
				strcpy(str2,str);
				if(change(str2,a,b)){
					goto end;
				}
			}
		}
end:
		printf("%s\n",str2);
	}
	
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
#include <sstream>
using namespace std;
 
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair
 
static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;
 
template <class T>
void initvv(vector<vector<T> > &v,int a,int b, const T  &t = T()){
    v.assign(a,vector<T>(b,t));
}
 
//v.erase(unique(v.begin(),v.end()),v.end());


int main(){
	int n;
	cin>>n;
	// cout<<n<<endl;
	string aaa;
	getline(cin,aaa);
	rep(i,n){
		string s;
		getline(cin,s);
		// cout<<s<<endl;
		string s2=s;
		rep(j,s.size()){
			if(s2[j]==' '){
				s2[j]=-1;
			}
			else{
				s2[j]=s2[j]-'a';
			}
		}
		string ans;
		bool f=false;
		rep(j,1000){
			if(j%2==0||j%13==0){
				continue;
			}
			rep(k,26){
				string tmp=s2;
				rep(l,s2.size()){
					if(tmp[l]==-1){
						tmp[l]=' ';
					}
					else{
						tmp[l]=(j*tmp[l]+k)%26;
						tmp[l]+='a';
					}
				}
				if(tmp.find("this",0)!=string::npos||tmp.find("that",0)!=string::npos){
					ans=tmp;
					f=true;
					break;
				}
				
			}
			if(f) break;
		}
		cout<<ans<<endl;
	}
}