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 <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)

static const double PI=6*asin(0.5);
typedef complex<double> P;
typedef long long ll;

int n;
vector<string> s;
vector<string> st;
string t;
vector<int> a;
vector<int> b;
int al,be;
int alpha=-1,beta=-1;

int afin(char s,int u,int t);

int gcd(int x,int y){
	if(y==0) return x;
	return gcd(y,x%y);
}
void atis(string st,int al,int be){
	if(afin(st[2],al,be)==0&&afin(st[3],al,be)==19){
		alpha=al;
		beta=be;
		
	}
	if(afin(st[2],al,be)==8&&afin(st[3],al,be)==18){
		alpha=al;
		beta=be;
		cout<<alpha<<" "<<beta<<endl;
	}
}

bool th(string st){
	int al,be;
	rep(i,a.size()){
		rep(j,b.size()){
			if(afin(st[0],a[i],b[j])==19&&afin(st[1],a[i],b[j])==7){
				al=a[i];
				be=b[j];
				atis(st,al,be);
				//cout<<al<<" "<<be<<endl;
			}
		}
	}
}
//abcdefghijklmnopqrstuvwxyz
//012345678901234567890123456
			


int afin(char s,int u,int t){
	int c=s-'a';
	//cout<<s<<" "<<c<<endl;
	return (u*c+t)%26;
}

int main(){
	cin>>n;
	//string thth="thth";
	//printf("%d %d\n",thth[0],thth[1]);
	rep(i,500){
		if(gcd(i+1,26)==1){
			a.push_back(i+1);
			//cout<<i+1<<endl;
		}
	}
	rep(i,26) b.push_back(i);
	rep(k,n){
		s.clear();
		st.clear();
		
		
		int i=0;
		char tmp[300]={0};
		string tm;
		string tt;
		char tmtm;
		gets(tmp);
		//cout<<1<<" "<<tmp<<endl;
		gets(tmp);
		//cout<<2<<" "<<tmp<<endl;
		//cout<<tmp<<endl;
		rep(i,300){
			if(tmp[i]=='\n'){
				s.push_back(tm);
				//cout<<tm<<endl;
				break;
			}
			else if(tmp[i]==' '){
				s.push_back(tm);
				//cout<<tm<<endl;
				tm.clear();
			}
			else{
				tt=tmp[i];
				tm+=tt;
			}
		}
		
		//gets(tmp);
		//cout<<3<<" "<<tmp<<endl;
		
		//cout<<tmp;
		
		rep(i,s.size()){
			if(s[i].size()==4){
				st.push_back(s[i]);
				//cout<<s[i]<<endl;
			}
		}
		rep(i,st.size()){
			th(st[i]);
			//if(alpa>0) cout<<"alpa="<<alpa<<" beta="<<beta<<endl;
		}
		
		rep(i,s.size()){
			rep(j,s[i].size()){
				printf("%c",afin(s[i][j],alpha,beta)+'a');
			}
			
			if(i!=s.size()-1)	cout<<" ";
			else cout<<endl;
		}
		s.clear();
		//cout<<"hoge"<<endl;
	}
	return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int gcd(int a,int b){
  if(a < b) swap(a,b);
  if(b == 0) return a;
  return gcd(b,a%b);
}

int lcm(int a,int b){
  return a*b/ gcd(a,b);
}
string Encode(string s,int n,int m){
  string res = s;
  rep(i,s.size()){
    if(s[i] != ' '){
      s[i] = (n * (s[i]-'a')+m )%26+'a';
    }
  }
  return s;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector< pair<string,pair<int,int>>> list(0);
  REP(i,1,26){
    if(gcd(i,26) == 1){
      rep(j,26){
        list.pb(make_pair(Encode("this",i,j),make_pair(i,j)));
        list.pb(make_pair(Encode("that",i,j),make_pair(i,j)));
      }
    }
  }
  int n,a,b;
  string s;
  cin >> n;
  cin.ignore();
  rep(i,n){
    vary(string,vs,0,"");
    getline(cin,s);
    string tmp="";
    rep(i,s.size()){
      if(s[i] == ' '){
        vs.pb(tmp);
        tmp.clear();
      }
      else tmp+=s[i];
    }
    vs.pb(tmp);
    rep(i,list.size()){
      rep(j,vs.size()){
        if(list[i].fi == vs[j]){
          a = list[i].se.fi;
          b = list[i].se.se;
        }
      }
    }
    s.clear();
    map<char,char> m;
    rep(i,26){
      char c[1] = {char('a'+i)};
      string str = c;
      m[Encode(str,a,b)[0]] = char('a'+i);
    }
    rep(i,vs.size()){
      rep(j,vs[i].size()){
        vs[i][j] = m[vs[i][j]];
      }
      s += vs[i];
      s += " ";
    }
    s.resize(s.size()-1);
    cout << s << endl;
  }
  return 0;
}

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

using namespace std;

int a, b;
const int alpha[] = {1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25};

inline char affine(char ch)
{
    return (alpha[a] * ch + b) % 26 + 'a';
}

void solve()
{
    string str;

    getline(cin, str);
    str += ' ';
    string::size_type pos1, pos2;
    bool flag = false;

    for (pos2 = str.find(' '), pos1 = 0; pos2 != string::npos;
         pos1 = pos2 + 1, pos2 = str.find(' ', pos1)) {
        if (str.substr(pos1, pos2 - pos1).size() == 4) {
            string tmp = str.substr(pos1, pos2 - pos1);

            for (int ai = 0; ai < 12; ai++) {
                for (int bi = 1; bi < 26; bi++) {
                    string cmp = "";
                    a = ai;
                    b = bi;

                    for (int i = 0; i < tmp.size(); i++) 
                        cmp.push_back(affine(tmp[i]));
                    if (cmp == "this" || cmp == "that") {
                        flag = true;
                        break;
                    }
                    if (flag)
                        break;
                }
                if (flag)
                    break;
            }
        }
        if (flag)
            break;
    }

    for (int i = 0; i < str.size() - 1; i++) {
        if (isalpha(str[i]))
            cout << affine(str[i]);
        else
            cout << str[i];
    }
    cout << endl;
}


int main()
{
    int n;
    
    cin >> n;
    cin.ignore();
    while (n--) {
        solve();
    }

    return 0;
}