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>

using namespace std; 
 
map<char, int> c2i;
map<int, char> i2c;
string str;
 
void init()
{
    for (char ch = 'a'; ch <= 'z'; ch++) {
	c2i[ch] = ch - 'a';
	i2c[ch - 'a'] = ch;
    }
}
 
bool serch(string s)
{
    return (s.find("that") != string::npos ||
            s.find("this") != string::npos);
}
 
char F(char ch, int a, int b)
{
    int num = (a * c2i[ch] + b) % 26; 
    return i2c[num];
}
 
int main()
{
    int n;
    
    cin >> n;
    cin.ignore();
    init(); 
    while (n--) {
	getline(cin, str);
 
	for (int i = 0; i < 26; i++) {
	    for (int j = 0; j < 26; j++) {
		string next;
		for (int k = 0; k < (int)str.size(); k++) {
		    if (islower(str[k])) {
                        next += F(str[k], i, j);
		    } else {
                        next += str[k];
                    }
                }
		if (serch(next)) {
		    cout << next << endl;
                    return 0;
		}
	    }
	}
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i,n) for(i=0;i<n;++i)
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define mp make_pair
#define pb push_back
#define fi first
#define sc second

int gcd(int p, int q){
  if(p<q) swap(p,q);
  while(q!=0){
    int tmp=p%q;
    p=q;
    q=tmp;
  }
  return p;
}

int main(int argc, char const *argv[]) {
  int i,j,k;

  string a="abcdefghijklmnopqrstuvwxyz";

  int n;
  scanf("%d\n",&n);
  for(int times=0; times<n; ++times){
    string s;
    getline(cin,s);
    //cout << s << endl;

    string ans;
    bool end=false;

    for(i=1; i<=25; ++i){//??¢???????????????
      if(gcd(26,i)!=1) continue;

      rep(j,26){
        //????????£?????§????¨?
        set<int> ch;
        rep(k,a.size()) ch.insert((i*k+j)%26);
        //??????
        if(ch.size()!=a.size()) continue;

        //printf("(%d,%d)\n",i,j);
        //?????????
        ans="";
        int p=0;
        rep(k,s.size()){
          if('a'<=s[k] && s[k]<='z'){
            ans+='a'+(i*(s[k]-'a')+j)%26;
          }
          else{
            ans+=s[k];
            string tmp=ans.substr(p,k-p);
            //cout << tmp << endl;

            if(tmp=="this"||tmp =="that")
              end=true;

            p=k+1;
          }
        }

        if(end) break;
      }
      if(end) break;
    }

    std::cout << ans << std::endl;
  }
  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];
				fill(table,table+26,-1);
				for(int k=0;k<26;k++){
					table[F(i,j,k)] = k;
				}
				if(count(table,table,-1))continue;
				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<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	int i,n;
	scanf("%d\n",&n);
	for(i=0;i<n;i++){
		string str;
		char s[300];
		gets(s);
		str=s;
//cout<<str<<endl;
		int a,b;
		for(a=1;a<26;a+=2){
			if(a==13)continue;
			for(b=0;b<26;b++){
				string st="";
				int j;
				for(j=0;j<str.size();j++){
					if('a'<=str[j]&&str[j]<='z'){
						st+=((str[j]-'a')*a+b)%26+'a';
					}else{
						st+=str[j];
					}
				}
//if(st[0]=='i')cout<<st<<endl;
				string::size_type index1=st.find("that");
				string::size_type index2=st.find("this");
				if(index1!=string::npos||index2!=string::npos){
					cout<<st<<endl;
					goto end;
				}
			}
		}
		end:;
	}
	return 0;
}

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

int alpha,beta;

char f(int c) {
    if(c == ' ') return ' ';
    return (char)(((alpha*(c-'a')+beta)%26)+'a');
}

int main() {
    int n;
    string in;
    cin>>n;
    cin.ignore();
    while(n--) {
        getline(cin, in);
        for(alpha = 2; alpha<26; ++alpha) {
            if(26%alpha == 0) continue;

            for(beta = 0; beta <26; ++beta) {
                string ci = in;
                for(int i=0; i<ci.length(); ++i)
                    ci[i] = f(ci[i]);


                if(ci.find("this") != string::npos || ci.find("that") != string::npos) {
                    cout<<ci<<endl;
                    goto END;
                }
            }
        }
    END:;
    }
}

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);
	}
	long long 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['t'],mp[vec[flg[i]][3]]);
					check[3]=func(a,b,mp['i'],mp[vec[flg[i]][2]]) || func(a,b,mp['s'],mp[vec[flg[i]][3]]);
					if(check[0] && check[1] && ((check[2])||(check[3]))){
						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;
}