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 <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }


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

int main()
{
	int n;
	cin >> n;

	rep(i, n)
	{
		string str;
		cin.sync();
		getline(cin, str);

		for(int a = 0; ; a++)
		{
			if(a % 2 != 0 && a % 13 != 0)
			{
				rep(b, 25)
				{
					// Ï·Îe[u
					int v[26] = {0};
					rep(y, 26)
						v[f(y, a, b)] = y;
					

					// Ï·
					string con = str;
					rep(in, con.size())
						if('a' <= con[in] && con[in] <= 'z')
							con[in] = v[con[in] - 'a'] + 'a';

					// Î`FbN
					rep(in, con.size() - 3)
					{
						if(con.substr(in, 4) == "that" || con.substr(in, 4) == "this")
						{
							cout << con << endl;
							goto ng;
						}
					}
				}
			}
		}
ng:
		;
	}
}

C++: #include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
#include<map>
#include<cmath>
#include<complex>
using namespace std;

typedef complex<double> P;

#define X real()
#define Y imag()
typedef int kz;

kz gcd(kz a,kz b) { if(b==0) return a; else gcd(b,a%b); }

int main(){
    int mod=1000000007;
    int n,len,x,y;
    char s[260];
    scanf("%d",&n);
    while (fgets(s,260,stdin)!=NULL) {
    //for (int p=0;p<n;++p) {
        fgets(s,260,stdin);
        len=strlen(s)-1;
        bool flg=0;
        //printf("%s\n",s);
        for (int a=0;a<26;++a) {
            if (gcd(a,26)!=1) continue;
            for (int b=0;b<26;++b) {
                char chk[len];
                for (int c=0;c<len;++c) {
                    if (isalpha(s[c])) {
                        chk[c]=(((s[c]-'a')*a+b)%26)+'a';
                    }
                }
                for (int d=0;d<len;++d) {
                    if (!strncmp(&chk[d],"this",4) || !strncmp(&chk[d],"that",4)) {
                        x=a;
                        y=b;
                        flg=1;
                    }
                }
            }
        }
        char ans[len];
        for (int i=0;i<len;++i) {
            if (isalpha(s[i])) ans[i]=(((s[i]-'a')*x+y)%26+'a');
            else ans[i]=s[i];
        }
        if (flg && len>3) printf("%s\n",ans);
        flg=0;
    }
    return 0;
}

C++: 
//アフィン暗号のプログラム

#include <iostream>
#include <string>

using namespace std;

string henkan( string s ){
  string t;
  for( int i = 0 ; ; i++ ){
    for( int j = 0 ; j < 26 ; j++ ){
      t = s;
      for( int k = 0 ; k < t.size() ; k++ ){
	if( 'a' <= t[k] && t[k] <= 'z'){
	  t[k] = ( i * ( t[k] - 'a' ) + j ) % 26 + 'a';
       	}
      }
      if( t.find("that") != t.npos || t.find("this") != t.npos ){
	return t;
      }
    }
  }
}

int main(void){
  int n;
  cin >> n;
  cin.get();
  while(n--){
    string s;
    getline( cin, s );
    cout << henkan(s) << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <cctype>
#define conv(c) ((c) - 'a')
#define Rconv(c) ((c) + 'a')
using namespace std;

int main(){
  int n;
  cin >> n;
  cin.ignore();
  while(n--){
    string s,t,ans; getline(cin,s);

    for(int i=0;i<=25;i++){
      for(int j=0;j<=25;j++){
	t = s; ans = "";
	for(int k=0;k<t.size();k++){
	  if(isalpha(t[k])) ans += Rconv((conv(t[k])*i+j) % 26);
	  else ans += t[k];
	}
	if(ans.find("that") != string::npos || ans.find("this") != string::npos) goto exit;
      }
    }
  exit:;
    cout << ans << endl;
  }
}

C++: #include<iostream>
#include<string>
#include<algorithm>
using namespace std;
bool isalphad(char z){
	if(z>='a'&&z<='z')return true;
	else return false;
}
bool isans(string z){
	bool ok=false;
	for(int i=0;i<z.size()-3;i++){
		if(z[i]=='t'&&z[i+1]=='h'&&z[i+2]=='i'&&z[i+3]=='s')ok=true;
		if(z[i]=='t'&&z[i+1]=='h'&&z[i+2]=='a'&&z[i+3]=='t')ok=true;
	}
	return ok;
}
int main(){
	string s,c;
	int n;
	cin>>n;
	for(int u=0;u<n;u++){
		cin.ignore();
		getline(cin,s);
		if(isans(s))cout<<s<<endl;
		else{
		int a=0;
		bool ok=false;
		while(true){
			int b=0;
			while(true){
				c=s;
				for(int i=0;i<s.size();i++){
					if(isalphad(c[i])){
						c[i]='a'+((c[i]-'a')*a+b)%26;
					}
				}
				if(isans(c)){
					ok=true;
					break;
				}
				b++;
				if(b==27)break;
			}
			if(ok)break;
			a++;
			
		}
		cout<<c<<endl;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
#include <cstdio>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define pb(a) push_back(a)
int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  int num;
  cin>>num;
  cin.ignore();
  rep(i,num){
    string s,ss;
    getline(cin,s);
    bool flag = true;
    ss = s;
    rep(i,26){
      rep(j,26){
	if(ss.find("that") == string::npos & ss.find("this") == string::npos){
	  rep(k,s.size()){
	    ss=((((s[i]-'a')*i)+j)%26)+'a';
	    
	  }
	    
	}else{
	  cout<<ss<<endl;
	  flag = false;
	  break;
	}
      }
      if(!flag){
	break;
      }
    }
  }
}

C++: #include <bits/stdc++.h>

using namespace std;

string shift(string s, int a, int b) {
  for (int i = 0; i < s.size(); i++) {
    if (s[i] < 'a' || 'z' < s[i]) continue;
    s[i] = (a * (s[i] - 'a') + b) % 26 + 'a';
  }
  return s;
}

void solve(string s) {
  for (int i = 0; i < 26; i++) {
    if (i % 2 == 0 || i == 13) continue;
    for (int j = 0; j < 26; j++) {
      string w = shift(s, i, j);
      if (w.find("that") != string::npos || w.find("this") != string::npos) {
        cout << w << endl;
        i = j = 26;
      }
    }
  }
}

int main(void) {
  int n;
  cin >> n;

  cin.ignore();
  for (int i = 0; i < n; i++) {
    string s;
    getline(cin, s);
    solve(s);
  }

  return 0;
}