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<stdio.h>
#include<string.h>


#define MAX_STR 257
#define ALFA_NUM 26

using namespace std;

int gcd(int);

int main(){

	int n;
	char str[MAX_STR],fstr[MAX_STR];
	bool flag;
	
	scanf("%d",&n);
	
	for(int m=0;m<n;m++){
		flag=true;
		//fgetsの入力がsizeof(str)を超えたら捨てる
		fflush(stdin);
				
		fgets(str,sizeof(str),stdin);
		
		
		for(int i=0;i<27&&flag;i++){
			if(gcd(i)==1){
				for(int j=0;j<27&&flag;j++){
				
					memset(fstr,'\0',sizeof(fstr));
					
					for(int k=0;str[k]!='\0' && k<sizeof(str);k++){
						
						if(str[k]!='\n' && str[k]!=' '){
							fstr[k]=((i*(str[k]-'a')+j)%ALFA_NUM)+'a';
						}
						else if(str[k]!='\n'){
							fstr[k]=str[k];
						}					
					}
					
					if(strstr(fstr,"that")!=NULL||strstr(fstr,"this")!=NULL){
						printf("%s\n",fstr);
						flag=false;
						break;
					}
				}
			}
		}
	}
}

int gcd(int n){
	int temp,m;
	m=ALFA_NUM;
	if(n>m){
		temp=n;
		n=m;
		m=temp;
	}
	while(1){
		if(n==0){
			return m;
		}
		temp=n;
		n=m%n;
		m=temp;
	}
}

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

char decode(int a, int b, char c)
{
  return (a * (c - 'a') + b) % 26 + 'a';
}

int main()
{
  int N;
  string str;
  cin >> N;
  cin.ignore();
  //printf("N = %d\n", N);
  for (int i = 0; i < N; i++) {
    //if (i == 0) getline(cin, str);
    getline(cin, str);

    istringstream is(str);
    string tmp;
    vector<string> token;
    while (is >> tmp) {
      token.push_back(tmp);
    }
    /*for (int j = 0; j < token.size(); j++) {
      cout << token[j] << endl;
      }*/

    for (int a = 0; a < 26; a++) {
      for (int b = 0; b < 26; b++) {
	for (int j = 0; j < token.size(); j++) {
	  tmp = token[j];
	  for (int k = 0; k < token[j].size(); k++) {
	    tmp[k] = decode(a, b, tmp[k]);
	  }
	  if (tmp == "this" || tmp == "that") {
	    for (int k = 0; k < token.size(); k++) {
	      for (int l = 0; l < token[k].size(); l++) {
		cout << decode(a, b, token[k][l]);
	      }
	      if (k == token.size() - 1) {
		cout << endl;
		goto next;
	      } else {
		cout << " ";
	      }
	    }
	  }
	}
      }
    }
  next:;
  }
}

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

bool check(const string &str){
    int p=0;
    while((p=str.find("this", 0))!=string::npos){
        if((p==0||str[p-1]==' ') && (p+4>=str.length()||str[p+4]==' ')) return true;
    }
    p=0;
    while((p=str.find("that", 0))!=string::npos){
        if((p==0||str[p-1]==' ') && (p+4>=str.length()||str[p+4]==' ')) return true;
    }
    return false;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s, d;
    s.reserve(260);
    d.reserve(260);
    int n;
    cin>>n;
    getline(cin, s);
    for(int i=0; i<n; i++){
        getline(cin, s);
        for(int a=1; a<26; a+=2){
            if(a==13) continue;
            d=s;
            for(auto &c:d) if('a'<=c&&c<='z')c=((c-'a')*a)%26+'a';
            for(int b=0; b<26; b++){
                if(check(d)) {
                    cout<<d<<'\n';
                    goto ok;
                }
                for(auto &c:d){
                    if(c=='z') c='a';
                    else if('a'<=c&&c<'z') ++c;
                }
            }
        }
        ok:;
    }
    return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  int n;
  cin >> n;
  while(n--) {
    string s;
    cin.ignore();
    getline(cin,s);
    int f = 0;
    for (int a=0;f==0;a++) {
      string buf(s);
      REP(b,26) {
        REP(i,s.length()) {
          if (s[i]!=' ') {
            buf[i] = ((s[i]-'a')*a+b)%26 + 'a';
          }
        }
        if (buf.find("that")!=-1||buf.find("this")!=-1) {
          cout << buf << endl;
          f = 1;
          break;
        }
      }
    }
  }
}

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;
  rep(i,n){
    vary(string,vs,0,"");
    while(cin >> s){
      vs.pb(s);
    }
    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;
}