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;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)

string c;

string solve(){
    int n = c.size();
    string p(n, ' ');
    rep(a,26){
        if(__gcd(a,26) != 1) continue;
        rep(b,26){
            char dic[256];
            rep(x, 26){
                int y = (x*a + b) % 26;
                dic[y + 'a'] = x + 'a';
            }
            dic[(int)' '] = ' ';
            rep(i,n) p[i] = dic[(int)c[i]];
            if(p.find("this") != string::npos || p.find("that") != string::npos) return p;
        }
    }
    assert(false);
}

int main(){
    int n;
    cin >> n;
    cin.ignore();
    rep(i,n){
        getline(cin, c);
        cout << solve() << endl;
    }
}

C++: #include<iostream>
using namespace std;
int mod[]={1,3,5,7,9,11,15,17,19,21,23,25};
int main(){
  int n;
  cin >>n;
  cin.ignore();
  while(n--){
    string s,t;
    getline(cin,s);
    t = s;
    for(int i=0; i<12; i++){
      for(int j=0; j<26; j++){
	for(int k=0; k<s.size(); k++){
	  if(s[k]>='a' && s[k]<='z') t[k] = 'a'+((s[k]-'a')*mod[i]+j)%26;
	}
	if(t.find("this") != string::npos){cout <<t<<endl;goto flag;}
	if(t.find("that") != string::npos){cout <<t<<endl;goto flag;}
      }
    }
  flag:;
  }
  return 0;
}

C++: #include<iostream>
#include<cstring>
#include<set>
#include<map>
#define MAX 26
#include<algorithm>
#include<string>
using namespace std;
bool check(string s){
	for(int i=0;i<s.size()-3;i++){
		if((s.substr(i,4)=="that"||s.substr(i,4)=="this")&&(i==0||s[i-1]==' ')&&(i+4>=s.size()||s[i+4]==' '))
			return true;
	}
	return false;
}
int main(){
	int n;
	cin>>n;
	while(n>0){
		char S[300];
		n--;
		string s="";
		fgets(S,300,stdin);
		for(int i=0;i<strlen(S)-1;i++){
			s+=S[i];
		}
		for(int i=0;i<MAX;i++){
			for(int j=0;j<MAX;j++){
				if(__gcd(i,j)!=1){
					continue;
				}
				map<char,char> mp;
				set<int> st;
				for(int k=0;k<MAX;k++){
					int x;
					x=(i*k+j)%26;
					st.insert(x);
					mp[x+'a']=k+'a';
				}
				if(st.size()!=26)
					continue;
				string t=s;
				for(int k=0;k<s.size();k++){
					if(s[k]==' '){
						continue;
					}
					t[k]=mp[t[k]];
				}
				if(check(t)){
					cout<<t<<endl;
					goto end;
				}
			}
		}
		end:;
		
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <math.h>
#include <map>
#include <stdio.h>
#include <ctype.h>
#include <algorithm>
#include <stdlib.h>

using namespace std;

int main() {
    string y;
    
    int z[12]={1,3,5,7,9,11,15,17,19,21,23,25};
    
    int affine[12*26][26]={0};
    for(int a=0; a<12; a++){
        for(int b=0; b<26; b++){
            for(int i=0; i<26; i++){
                    affine[a*26+b][(i*z[a]+b)%26]=i;
            }
        }
    }
    
    int temp;
    scanf("%d",&temp);
    
    
    
    while(getline(cin,y)){
        string x=y;
        
        
        for(int j=0; j<12*26; j++){
            if(x.find("this")!=-1 || x.find("that")!=-1){
                cout<<x<<endl;
                break;
            }
            for(int i=0; i<(int)y.length(); i++){
                if(y[i]==' '){
                    
                }else{
                    x[i]=affine[j][y[i]-'a']+'a';
                }
            }
        }
        
        
        
    }
    
    
    
    return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
	int n , alpha , beta;
	string s,org;
	cin >> n;
	cin.ignore();
	for(int i=0;i<n;++i){
		getline(cin , s);
		org=s;
		while(1){
				for(alpha=3;alpha<26;++alpha){
						if(alpha){
							if(26%alpha==0) continue;
						}
					for(beta=0;beta<=26;++beta){
						for(int k=0;k<26;++k){
							if((s[0]-'a')==(alpha*k+beta)%26){
								for(int l=0;l<s.length();++l){
									for(int m=0;m<26;++m){
										if(isalpha(s[l])){
											int t=s[l]-'a';
											org[l]=(alpha*t+beta)%26+'a';
											}
										}
									}
								if(org.find("this" ,0)!=string::npos || org.find("that" , 0)!=string::npos) goto result;
							}
						}
					}
				}
		}
		result:;
		cout << org << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
	int n,i,j,k;string s,t;cin>>n;
	while(n--){getline(cin,s);t=s;
		for(i=1;i<30;i++)for(j=0;j<30;j++){
			for(k=0;k<s.size();k++)t[k]=s[k]-32?97+(i*s[k]+j)%26:32;
			if(t.find("this")+1||t.find("that")+1)i=j=30;
		}cout<<t<<endl;
	}return 0;
}

C++: #include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };

int main() {
	int n;
	string ns;
	getline(cin, ns);
	n = atoi(ns.c_str());
	while (n--){
		string s;
		getline(cin, s);
		for (int i = 1; i < 26; i += 2){
			if (i == 13)
				continue;
			REP(j, 26){
				string s2 = s;
				REP(k, s.length()){
					if ('a' <= s2[k] && s2[k] <= 'z'){
						s2[k] = 'a' + ((s2[k]-'a') * i + j) % 26;
					}
				}
				if (s2.find("that") != string::npos || s2.find("this") != string::npos){
					s = s2;
					i = j = 26;
				}
			}
		}
		cout << s << endl;
	}
}

C++: #include<iostream>
#include<string>
using namespace std;
int main()
{
  int n;
  cin>>n;cin.ignore();
  for(;n--;)
    {
      string s;
      getline(cin,s);
      //      cout<<s<<endl;
      //    return 0;
      for(int a=0;a<1000;a++)
	for(int b=0;b<1000;b++)
	  {
	    if(a%26==0 ||26%a==0)
	      continue;
	    string tmp;
	    tmp=s;
	    for(int i=0;i<tmp.size();i++)
	      {
		if(tmp[i]>='a'&&tmp[i]<='z')
		  {
		    tmp[i]=((a*tmp[i]-'a'+b)%26)+'a';
		  }
	      }
	    if( tmp.find( "that", 0 ) != string::npos || tmp.find( "this", 0 ) != string::npos )
	      {
		cout <<tmp << endl;
		a=1001;
		b=1001;
	      }
	    //	    else
	      //  cout<<tmp<<endl<<a<<" "<<b<<endl;
	  }
    }

}