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 <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;
inline int toInt(string s){int v;istringstream i(s);i>>v;return v;}
template<class T> inline string toString(T x){ostringstream o;o<<x;return o.str();}
template<class T> void pv(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}
const int INF = 1000000000;
const double EPS = 1e-10;

string decode(string s, int alpha, int beta) {
	for(string::iterator it = s.begin(); it != s.end(); ++it) {
		if(isalpha(*it)) *it = (alpha * (*it - 'a') + beta) % 26 + 'a';
	}
	return s;
}

int main() {
	int N;
	cin >> N;
	cin.ignore();
	while(N--) {
		string line;
		getline(cin, line);
		string ans = "";
		for(int i = 0; i < 26; i++) {
			for(int j = 0; j < 26; j++) {
				string s = decode(line, i, j);
				if(s.find("that") != string::npos || s.find("this") != string::npos) {
					ans = s;
				}
			}
		}
		cout << ans << endl;
	}
}

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

int main() {
  string str,w1,w2;
  int n,a,b,c;
  int da[26];
  cin >> n;
   while(n>0) {
	  getline(cin,str);
	  if (str.size()==0) continue;
	    for (a=1;a<26;a+=2) {
		  if (a==13) continue;
		  for (b=0;b<26;b++) {
			  w1="this"; w2="that";
			  for (c=0;c<4;c++) {
				  w1[c]=char('a'+((a*(w1[c]-'a')+b) % 26));
                  w2[c]=char('a'+((a*(w2[c]-'a')+b) % 26));
			  }
              if (str.find(w1)!=string::npos || str.find(w2)!=string::npos) break;
		  }
		  if (b<26) break;
	  }
		for (c=0;c<26;c++) da[(a*c+b) % 26]=c;
		for (c=0;c<str.size();c++) {
			if (str[c]==' ') cout << ' '; 
			else cout << (char)('a'+da[str[c]-'a']);
		}
        cout << endl;
    n--;
   }
  return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<string.h>

int main()
{
	int n;
	std::cin >> n;
	
	while( n-- ){
		char s[257], t[257];
		char a[26];
		
		fgets( s, 256, stdin );
		
		strcpy( t, s );
		
		for( int i = 1; i <= 26; i += 2 ){
			for( int j = 0; j < 26; j++ ){
				if( i % 13 == 0 ) continue;
				
 				for( int k = 0; k < 26; k++ ){
				 	a[ ( i * k + j ) % 26 ] = k + 'a';
				}
				
				for( int k = 0; k < strlen( t ); k++ ){
					if( s[k] == ' ' || s[k] == '\n' ) continue;
					
					s[k] = a[ t[k] - 'a' ];
				}
				
				if( strstr( s, "that" ) != NULL || strstr( s, "this" ) != NULL ){
					std::cout << s;
				}
				
				strcpy( s, t );
			}
		}
	}

 	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cctype>
using namespace std;

int conv(int ch, int a, int b) {
  if ( !isalpha(ch) ) return ch;
  int n = ch - 'a';
  return (char)('a' + (a * n + b) % 26);
}

int valid(int a, int b) {
  int count[26] = {};
  for(int n = 0; n < 26; n++) {
    if ( ++count[conv(n + 'a', a, b) - 'a'] >= 2 )
      return 0;
  }
  return 1;
}

int check(string line, int a, int b) {
  if ( !valid(a, b) ) return 0;

  for(int i = 0; i < (int)line.size(); i++)
    line[i] = conv(line[i], a, b);

  return line.find("that") != string::npos ||
    line.find("this") != string::npos;
}

int main() {
  int T; cin >> T >> ws;
  while(T--) {
    string line;
    getline(cin, line);

    for(int a = 0; a < 26; a++)
      for(int b = 0; b < 26; b++) {
        int res = check(line, a, b);
        if ( res ) {
          for(int i = 0; i < (int)line.size(); i++)
            cout << (char)conv(line[i], a, b);
          cout << endl;
        }
      }
  }
  return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;




int main(){


    int n;
    string s;
    string p;
    (cin >> n).ignore();
    cin.ignore();

    while(n--){
        
        getline(cin,s);
        
        for(int i = 0;i < 26;i++){
            
            for(int j = 0;j < 26;j++){

                string t = s;

                for(int k = 0;k < t.size();k++){

                    if(islower(t[k])){
                        t[k] = ((t[k]-'a')*i + j) % 26 + 'a';
                    }

                }
                if(t.find("this") != -1 || t.find("that") != -1){
                    cout << t << endl;
                    cout << i << " " << j << endl;
                    i = j = 30;
                }

            }
        }
    }


    return 0;

}

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

char encode(char y, int a, int b) {
    if (islower(y)) {
        int n = y - 'a';
        return (a * n + b) % 26 + 'a';
    } else {
        return y;
    }
}

string encode(string s, int a, int b) {
    string t;
    for (int i = 0; i < s.size(); i++) {
        t.push_back(encode(s[i], a, b));
    }
    return t;
}

string s;

bool check(string t) {
    return s.find(t) != string::npos;
}

map<char, char> decode_table;
void create_decode_table(int a, int b) {
    for (int i = 'a'; i < 'a'+26; i++) {
        decode_table[encode(i, a, b)] = i;
    }
}

string decode(string t) {
    string u;
    for (int i = 0; i < t.size(); i++) {
        if (islower(t[i])) {
            u.push_back(decode_table[t[i]]);
        } else {
            u.push_back(' ');
        }
    }
    return u;
}

int main() {
    int n; cin >> n;
    cin.ignore(1);
    while (n--) {
        getline(cin, s);
        for (int a = 0; a < 26; a++) {
            for (int b = 0; b < 26; b++) {
                //cout << encode("that", a, b) << endl;
                if (check(encode("that", a, b)) || check(encode("this", a, b))) {
                    create_decode_table(a, b);
                    cout << decode(s) << endl;
                    break;
                }
            }
        }
    }
    return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	int n,i,j,k;string s,t;cin>>n;
	while(n--){getline(cin,s);t=s;
		for(i=0;i<99;i++)for(j=0;j<26;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=99;
		}cout<<t<<endl;
	}return 0;
}