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++: #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

#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++)
#define OP(m) cout << m << endl;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    map<char, int> t;
    int n;
    char m[26];
    string suuti;
    getline(cin, suuti);
    n = stoi(suuti);
    rep(i, 26)
    {
        m[i] = char('a' + i);
        t[m[i]] = i;
    }

    rep(i, n)
    {
        string s, s_trans;
        bool flag = 0;
        getline(cin, s);
        s_trans = s;
        rep(a, 26)
        {
            rep(b, 26)
            {
                rep(k, s.size())
                {
                    if (s[k] == ' ')
                        s_trans[k] = ' ';
                    else
                        s_trans[k] = m[a * (t[s[k]] - b + 26) % 26];
                }
                if (s_trans.find("this") != string::npos || s_trans.find("that") != string::npos)
                {
                    flag = 1;
                    break;
                }
            }
            if (flag == 1)
                break;
        }
        OP(s_trans)
    }

    return 0;
}

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

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

string solve(string cipher)
{
  for ( ; ; ) {
    for (int a = 1; ; ++a) {
      if (gcd(a, 26) != 1)
	continue;
      bool decrypt = false;
      for (int b = 0; b < 26; ++b) {
	string plain = cipher;
	for (unsigned int i = 0; i < plain.size(); ++i) {
	  if (isalpha(plain[i]))
	    plain[i] = ('a' + ((a * (plain[i]-'a') + b) % 26));
	}
	if (plain.find("that") != string::npos || plain.find("this") != string::npos)
	  return plain;
      }
    }
  }
}

int main()
{
  int n;
  cin >> n;
  string cipher;
  getline(cin, cipher);
  for (int i = 0; i < n; ++i) {
    getline(cin, cipher);
    if (cipher.find_first_of("\n") != string::npos)
      cipher.erase(cipher.end()-1);
    if (cipher.find_first_of("\r") != string::npos)
      cipher.erase(cipher.end()-1);
    cout << solve(cipher) << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(o) {cerr<<#o<<" "<<o<<endl;}
#define DUMPC(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

//?????§??¬?´???°
int gcd(int x, int y) {
	return y ? gcd(y, x%y) : x;
}

signed main() {
	int n; cin >> n; cin.ignore();
	REP(i, n) {
		string S; getline(cin, S);
		REP(a, 26) {
			if (gcd(a, 26) != 1)continue;
			REP(b, 26) {
				string T = S;
				REP(j, S.size()) {
					if (S[j] == ' ') {
						continue;
					}
					int c = S[j] - 'a';
					c = (a*c + b) % 26;
					T[j] = char(c + 'a');
				}
				if (T.find("that") == string::npos&&T.find("this") == string::npos) {
					continue;
				}
				else {
					cout << T << endl;
					a = b = 26;
				}
			}
		}
	}
	return 0;
}

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

int main(){
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		string s;
		getline(cin,s);
		istringstream t(s);
		bool x = false;
		string u[1000];
		for(int a=0;a<26;a++){
			for(int b=0;b<=26;b++){
				int c = 0;
				while(getline(t,u[c],' ')){
					for(int j=0;j<u[c].size();j++) u[c][j] = (a*u[c][j]+b-'a')%26 + 'a';
					if(u[c]=="that" or u[c]=="this") x = true;
					c++;
					cout << u[c] << endl;
				}
				if(x){
					cout << u[0];
					for(int j=1;j<c;j++) cout << " " << u[j];
					cout << endl;
					return 0;
				}
			}
		}
	}
}

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

using namespace std;

main(){
  int n;
  string data[100];
  string tmp[100];
  cin >> n;
  for(int i=0;i<n;i++){
    int size;
    for(size=0;;size++){
      cin >> data[size];
      char c;
      scanf("%c", &c);
      if(c=='\n'){
	break;
      }
    }
    size++;
    for(int i=3;i<26;i+=2){
      for(int j=0;j<26;j++){
	for(int k=0;k<size;k++){
	  tmp[k]="";
	}
	for(int a=0, b=0;a<size;b++){
	  if(data[a].size()<=b){
	    a++;
	    b=-1;
	    continue;
	  }
	  char c=(char)((i*(int)(data[a][b]-'a')+j)%26);
	  c+='a';
	  tmp[a]+=c;
	}
	for(int k=0;k<size;k++){
	  if(tmp[k]=="that" || tmp[k]=="this"){
	    for(int l=0;l<size;l++){
	      cout << tmp[l];
	      if(l==size-1) cout << endl;
	      else cout << ' ';
	    }
	    return 0;
	  }
	}
      }
    }
  }
  return 0;
}

C++: #include<iostream>
#include<map>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>
#include<cmath>
using namespace std;
int inf = 1000000000;

char affine(char c, int a, int b){
  int x = c - 'a';
  int y = ( a * x + b ) % 26;
  char r = 'a' + y;
  return r;
}

int main(){

  int n;
  cin >> n;
  cin.ignore();
  for(int l=0; l<n; l++){
    string s;
    getline(cin, s);

    for(int i=0; i<50; i++){
      if( i == 2 || i == 13 ) continue;
      for(int j=0; j<50; j++){
        string t = "";
        for(int k=0; k<s.size(); k++){
          if( 'a' <= s[k] && s[k] <= 'z' ) t += affine(s[k], i, j);
          else t += s[k];
        }
        for(int k=0; k<t.size()-4; k++){
          if( (t[k] == 't' && t[k+1] == 'h' && t[k+2] == 'a' && t[k+3] == 't') || (t[k] == 't' && t[k+1] == 'h' && t[k+2] == 'i' && t[k+3] == 's') ) cout << t << endl;
        }
      }
    }

  }


  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;char st;
    cin>>n;
    string str;
    for(int i=0;i<=n;i++){
        getline(cin,str);
        bool kawa=0;
        for(int j=1;j<50&&!kawa;j++){
            for(int k=1;k<50&&!kawa;k++){
                string strin=str;
                for(int l=0;strin[l]!='\0';l++)if(strin[l]-'a'>=0&&strin[l]-'z'<=0)strin[l]=(j*(strin[l]-'a')+k)%26+'a';
                for(int l=0;strin[l]!='\0';l++){
                    if(strin[l]=='t'&&strin[l+1]=='h'&&(strin[l+2]=='a'&&strin[l+3]=='t'||strin[l+2]=='i'&&strin[l+3]=='s')){
                        cout<<strin<<endl;
                        kawa=1;
                        break;
                    }
                }
            }
        }
    }
}