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 <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
	int n , alpha , beta;
	string s,org;
	cin >> n;
	cin.ignore();
	for(int i=0;i<n;++i){
		getline(cin , s);
		org=s;
		while(1){
				for(alpha=3;alpha<26;++alpha){
						if(alpha){
							if(26%alpha==0) continue;
						}
					for(beta=0;beta<=26;++beta){
						if (org.find("this" ,0)!=string::npos || org.find("that" , 0)!=string::npos) {
							cout << org << endl;
							goto skip;
						} else {
							for(int k=0;k<26;++k){
							if((s[0]-'a')==(alpha*k+beta)%26){
								for(int l=0;l<s.length();++l){
									for(int m=0;m<26;++m){
										if(isalpha(s[l])){
											int t=s[l]-'a';
											org[l]=(alpha*t+beta)%26+'a';
											}
										}
									}
								}
							}
						}
						
					}
				}	
		}
		skip:;
	}
	return 0;
}

C++: #include<algorithm>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int gcd(int p,int q){
  int s;
  while(q){
    p%=q;
    s=p;
    p=q;
    q=s;
  }
  return p;
}
int main(){
  int i,j;
  int a,b,n;
  int ln;
  string s,t;
  cin>>n;
  getline(cin,s);
  for(i=0;i<n;i++){
    getline(cin,s);
    ln=s.length();
    for(a=1;a<26;a++){
      if(gcd(26,a)==1){
	for(b=0;b<26;b++){
	  t="";
	  for(j=0;j<ln;j++){
	    if('a'<=s[j]&&s[j]<='z')
	      t+=(a*(s[j]-'a')+b)%26+'a';
	    else
	      t+=s[j];
	  }
	  if(t.find("that")!=string::npos||t.find("this")!=string::npos)
	    break;
	}
	if(b!=26)
	  break;
      }
    }
    cout<<t<<endl;
  }
  return 0;
}

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

using namespace std;

int gcd(int x,int y){
  if(y == 0)return x;
  return gcd(y,x%y);
}

int lcm(int x,int y){
  return (x*y)/gcd(x,y);
}

string affine(string s,int a,int b){
  string news;
  for(int i=0;i<s.length();i++){
    if(!('a'<= s[i] && s[i]<='z') ){
      news+=s[i];
      continue;
    }
    int y = s[i]-'a';
    news+= (char)((a*y+b)%26+'a');
  }

  return news;
}


int main(){

  int N;
  string s;
  cin >> N;
  cin.ignore();
  while(N-- > 0){
    getline(cin,s,'\n');
   
    bool fin = false;
    for(int a=0;a<=99;a++){
      if(gcd(a,26) == 1){
	for(int b=0;b<=99;b++){
	  string Ns = affine(s,a,b);	  
	  if(Ns.find("that") != string::npos || Ns.find("This") != string::npos){
	    cout << Ns << endl;
	    fin = true;
	    break;
	  }
	}
	if(fin)break;
      }
      }



  }
  return 0;
}

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

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

int main(void)
{
	int n;
	string a;
	getline(cin, a);
	
	n = atoi(a.c_str());
	for (int i = 0; i < n; i++){
		// cout << "*" << endl;
		string str;
		getline(cin, str);
		
		for (int a = 0; a < 100; a++){
			for (int b = 0; b < 100; b++){
				string tmp = str;
				for (int j = 0; j < str.size(); j++){
						if (tmp[j] == '.') continue;
						if (tmp[j] == ' ') continue;
						if (isdigit(tmp[j])) continue;
						tmp[j] = func(a, b, str[j] - 'a') + 'a';
				}
				
				if (tmp.find("that") != string::npos || tmp.find("this") != string::npos){
					cout << tmp << endl;
					goto a;
				}
			}
		}
		a:;
	}
	
	return 0;
}

C++: #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define VI(a,n) vi a(n); rep(i,n)cin>>a[i];
#define sq(n) (n)*(n)

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

char change(int a,int b,char c){
    return c==' '?c:(a*(c-'a')+b)%26+'a';
}

void run(){
    int n;
    cin>>n;
    cin.ignore();
    while(n--){
        string s;
        getline(cin,s);
        REP(i,3,27){
            if(i==2||i==13||i==26)continue;
            REP(j,1,27){
                string ans=s;
                rep(k,s.length()){
                    ans[k]=change(i,j,s[k]);
                }
                if(ans.find("this")!=string::npos||ans.find("that")!=string::npos){
                    cout<<ans<<endl;
                    goto BR;
                }
            }
        }
        BR:;
    }
}

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

#define A 12

int main()
{
  int n,i,j;
  int alpha[A]={3,5,7,9,11,13,15,17,19,21,23,25},beta;
  string s,t;
  bool f;
  getline(cin,s);
  while(getline(cin,s)){
    f=true;
    t=s;
    if(t.find("this ",0)==0)f=false;
    if(t.find("that ",0)==0)f=false;
    if(t.find(" this",t.size()-5)==t.size()-5)f=false;
    if(t.find(" that",t.size()-5)==t.size()-5)f=false;
    if(t.find(" this ")!=string::npos)f=false;
    if(t.find(" that ")!=string::npos)f=false;
    for(i=0;f && i<A;i++){
      for(beta=0;f && beta<26;beta++){
	t=s;
	for(j=0;j<t.size();j++){
	  if(t[j]==' ')continue;
	  t[j]-='a';
	  t[j]=(t[j]*alpha[i]+beta)%26;
	  t[j]+='a';
	}
	if(t.find("this ",0)==0)f=false;
	if(t.find("that ",0)==0)f=false;
	if(t.find(" this",t.size()-5)==t.size()-5)f=false;
	if(t.find(" that",t.size()-5)==t.size()-5)f=false;
	if(t.find(" this ")!=string::npos)f=false;
	if(t.find(" that ")!=string::npos)f=false;
      }
    }
    cout<<t<<endl;
  }
}