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"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

ll gcd(ll a,ll b){
	if(a<b){
		swap(a,b);
	}

	while(ll r=(a%b)){
		a = b;
		b = r;
	}
	return b;
}

vector<string> split_naive(const string &s, char delim) {
	vector<string> elems;
	string item;
	for(char ch:s){
		if(ch==delim){
			if(!item.empty()) elems.push_back(item);
			item.clear();
		}
		else{
			item += ch;
		}
	}
	if(!item.empty()) elems.push_back(item);
	return elems;
}

ll extend_gcd(ll a,ll b,ll &x,ll &y){
	if(b==0){
		x = 1;
		y = 0;
		return a;
	}
	ll d = extend_gcd(b,a%b,y,x);
	y -= a/b * x;
	return d;
}

ll mod(ll a,ll m){
	return (a%m+m)%m;
}

ll modinv(ll a,ll m){
	ll x,y;
	extend_gcd(a,m,x,y);
	return mod(x,m);
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	vector<int> A,Ainv;
	REP(i,26){
		if(gcd(i+1,26)==1){
			A.push_back(i+1);
		}
	}
	int N;
	char S[280];
	cin.getline(S,sizeof(S));
	sscanf(S,"%d",&N);
	REP(n,N){
		cin.getline(S,sizeof(S));
		auto T = split_naive(string(S),' ');
		bool exist = false;
		int ansA,ansB;
		for(auto& alpha:A){
			for(int beta=0;beta<26;beta++){
				string THAT = "that";
				string THIS = "this";
				for(int i=0;i<4;i++){
					THAT[i] = (char)((alpha*(THAT[i]-'a')+beta)%26)+'a';
					THIS[i] = (char)((alpha*(THIS[i]-'a')+beta)%26)+'a';
				}
				for(auto& x:T){
					if(x==THAT || x==THIS){
						exist = true;
						break;
					}
				}
				if(exist){
					ansB = beta;
					break;
				}
			}
			if(exist){
				ansA = alpha;
				break;
			}
		}
		for(int i=0,ei=280;i<ei;i++){
			if(S[i]>='a' && S[i]<='z'){
				S[i] = (char)((modinv(ansA,26)*mod((S[i]-'a')-ansB,26))%26)+'a';
			}
		}
		out(S);
	}

	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)):((m)-(n))),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)
#define loop for(;;)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;
typedef vector<int> vi;
typedef vector<string> vs;
typedef map<string,int> Dictionary;
const Real PI = acos(-1);

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

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

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

string affin(string s, int a, int b) {
  string r = "";
  rep (i, s.size()) {
    char c = s[i];
    if ('a' <= c && c <= 'z') {
      r += affin(c, a, b);
    }
    else {
      r += c;
    }
  }
  return r;
}

bool okay(string s) {
  if (s.find("this") != string::npos) return true;
  if (s.find("that") != string::npos) return true;
  return false;
}

int main() {

  int n; cin >> n;
  getchar();

  rep (_, n) {
    string s;
    getline(cin, s);

    rep (a, 26) {
      if (a % 2 == 0) continue;
      if (a % 13 == 0) continue;
      rep (b, 26) {
        string t = affin(s, a, b);
        if (okay(t)) {
          cout << t << endl;
          goto more;
        }
      }
    }
more:;
  }

  return 0;
}

C++: #include<iostream>
#include<string>
#include<stdio.h>
#include<ctype.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	string s;
	char r[257];
	for(int u=0;u<n;u++){
	    cin.ignore();
		getline(cin,s);
		int a=0,b=0;
		bool end=false;
		while(true){
			b=0;
			while(true){
		        for(int i=0;i<s.size();i++){
					if(isalpha(s[i])!=0)
			            r[i]=((s[i]-'a')*a+b)%26+'a';
					else
						r[i]=s[i];
				}
				for(int i=0;i<s.size()-3;i++){
					if(r[i]=='t'&&r[i+1]=='h'&&r[i+2]=='i'&&r[i+3]=='s'){
						end=true;
						break;
					}
					if(r[i]=='t'&&r[i+1]=='h'&&r[i+2]=='a'&&r[i+3]=='t'){
						end=true;
						break;
					}
				}
				if(end)break;
				if(b==26)break;
				b++;
			}
			if(end)break;
			a++;
		}
		for(int i=0;i<s.size();i++)
			cout<<r[i];
		cout<<endl;
	}
	return 0;
}

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);
		//memset(str,'\0',sizeof(str));
		
		fgets(str,sizeof(str),stdin);
		
		
		for(int i=0;flag==true;i++){
			if(gcd(i)==1){
				for(int j=0;flag==true;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;
					}
				}
			}
		}
	
		//fgetsの入力がsizeof(str)を超えたら捨てる
		//fflush(stdin);
	}
}

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