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;

using db = double;
using ll = long long;
using vi = vector <int>;
#define op operator
#define pb push_back

string trans(string s, int a, int b) {
	for(auto &c : s) if(isalpha(c)) {
		int t = c - 'a';
		t = (t * a + b) % 26;
		c = t + 'a';
	}
	return s;
}

int main() {
	ios :: sync_with_stdio(0);

	int n; cin >> n;
	string s; getline(cin, s);
	while(n --) {
		getline(cin, s);
		for(int a = 1; a < 26; a ++)
			for(int b = 0; b < 26; b ++) if(__gcd(a, b) == 1) {
				string t = trans(s, a, b);
				bool f = 0;
				for(int i = 0; i < t.size(); i ++)
					if(t.substr(i, 4) == "this" || t.substr(i, 4) == "that")
						f = 1;
				if(f) {
					cout << t << '\n';
					goto done;
				}
			}
		done: ;
	}

	return 0;
}

C++: 
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
#endif

#define ITER(c)         __typeof__((c).begin())
#define FOREACH(it, c)  for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)        __typeof__((c).rbegin())
#define RFOREACH(it, c) for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)       REPEAT(i, 0, n)
#define REPEAT(i, k, n) for (int i = (k); i < (n); ++i)
#define REVREP(i, n)    for (int i = ((n)-1); i >= 0; --i)
#define FIND(c, n)      std::find((c).begin(), (c).end(), (n));
#define BSEARCH(c, n)   std::binary_search((c).begin(), (c).end(), (n))
#define LLPOW(p1,p2)    ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A)      (sizeof(A)/sizeof((A)[0]))
#define MIN(p1,p2)      (((p1)<(p2))?(p1):(p2))
#define MAX(p1,p2)      (((p1)>(p2))?(p1):(p2))
#define CIN_NO_SYNC     do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p)       fgets((p), sizeof(p), stdin)
#define CHOMP(p)        do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n') *_q = 0; } while(0)

typedef long long ll;
typedef unsigned long long ull;

#ifdef _DEBUG
#define pf printf
#define pr(n) do { cout << #n " = " << (n) << endl; } while(0)
#else
#define pf(...) /* */
#define pr(...) /* */
#endif

ll gcd(ll num1, ll num2){ return num2 == 0 ? num1: gcd(num2, num1 % num2); }

// F(r) = (ar + b) mod 26 
// r = F(r) - b + 26k) ≡ 0 (mod a)
char decode(const char ch, int n, int a, int b){
    if(!islower(ch)) return ch;
    int t = (ch - 'a') - b;
    while(t < 0 || t % a != 0) t += n;
    return 'a' + (t/a) % n;
}

int main(){
    string s;
    getline(cin, s);
    int n;
    sscanf(s.c_str(), "%d", &n);

    REP(i,n){
        getline(cin, s);
        REPEAT(j,1,26){
            if(gcd(26,j) != 1) continue;
            REP(k,26){
                string t = s;
                int len = t.size();

                REP(l,len){
                    t[l] = decode(t[l], 26, j, k);
                }

                pf("%d:%d %s\n", j, k, t.c_str());
                char buf[260];
                sprintf(buf, " %s ", t.c_str());
                if(strstr(buf, " that ") != NULL || strstr(buf, " this ") != NULL){
                    cout << t << endl;
                    goto END;
                }
            }
        }
END:;
    }

    return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <sstream>
#include <istream>
#include <cmath>
#include <cstdio>

using namespace std;

#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapii map<int, int>
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()
#define minit(a, i) memset(a, i, sizeof(a));

#define for_(i, a, b) for (int i=(int)a; i<(int)b; i++)
#define for_d(i, a, b) for (int i=(int)a-1; i>=b; i--)
#define for_r(i, a, b, c) for (int i=(int)a; i<(int)b; i += c)
#define for_dr(i, a, b, c) for (int i=(int)a-1; i>=b; i -= c)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

typedef long long ll;

const int iINF = 2147483647;
const ll lINF = 9223372036854775807;

template <class T> inline void dbg(T t) { cout << t << endl; }




vcs splitAll(string s, string t) {
	vcs r;
	for (int p = 0; (p = s.find(t)) != s.npos;) {
		r.pb(s.substr(0, p));
		s = s.substr(p + t.size());
	}
	r.pb(s);
	return r;
}

int BETA;
int ALPH;

char func(char c) {
	int t = (ALPH*((int)(c-'a')) - BETA + 26)%26;
	char ret = 'a' + t;
	return ret;
}

ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a%b) : a; }

int main() {
	int n; cin >> n;
	cin.ignore(1);
	
	for_(i, 0, n) {
		string in;
		getline(cin, in);
		
		int m = (int)in.sz;
		BETA = 0;
		ALPH = 0;
		while (1) {
			if (BETA==26) {
				BETA = 0;
				while (gcd(++ALPH, 26)!=1) { }
			}
			
			string str = in;
			for_(j, 0, m) {
				if (str[j]==' ') continue;
				str[j] = func(str[j]);
			}		
			if (str.find("this")!=str.npos || str.find("that")!=str.npos) {
				in = str;
				break;
			}
			BETA++;
		}
		
		cout << in << endl;
	}
	
	return 0;
}

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

int n;
char buf[1000];
int invmod[] = {0, 1, 0, 9, 0, 21, 0, 15, 0, 3, 0, 19, 0, 0, 0, 7, 0, 23, 0, 11, 0, 5, 0, 17, 0, 25};

string decrypt(string s, int a, int b) {
  string ret;

  if (invmod[a]*a%26 != 1) return "";
   
  for (int i=0; i<s.size(); i++) {
    if (s[i] == ' ') ret += ' ';
    else {
      int k = (s[i]-'a'-b+26)%26;
      ret += 'a'+k*invmod[a]%26;
    }
  }

  return ret;
}

void process() {
  fgets(buf, sizeof(buf), stdin);
  char *sp = strchr(buf, '\n');
  if (sp != NULL) *sp = '\0';

  for (int i=0; i<26; i++) {
    for (int j=0; j<26; j++) {
      string decoded = decrypt(buf, i, j);
      if (decoded.find("that") != string::npos) {
        printf("%s\n", decoded.c_str());
        return;
      }

      if (decoded.find("this") != string::npos) {
        printf("%s\n", decoded.c_str());
        return;
      }
    }
  }
}

int main() {
  scanf("%d ", &n);
  while (n--) {
    process();
  }
}