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 <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
using namespace std;
int main(){
	

	int n;
	cin>>n;
	cin.ignore();
	while(n>0){
		string s;
		bool f=false;
		getline(cin,s);
		for(int b=0;b<=26;b++){
			
			for(int a=0;a<=26;a++){
				string ans=s;
				if(a%2!=0&&a%13!=0){
					for(int i=0;i<ans.size();i++){
						if(ans[i]>='a'&&ans[i]<='z'){
							ans[i]='a'+(a*(ans[i]-'a')+b)%26;
						}
					}
					if(ans.find("that")!=-1||ans.find("this")!=-1){
						cout<<ans<<endl;
						f=true;
						break;
					}
				}
			}
			if(f)
				break;
		}
		
	
		n--;
	}
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cctype>
#include<cstdlib>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
    int n;
    cin>>n;
    while(n--){
        cin.ignore();
        string str;
        getline(cin,str);
        bool f=false;
        for(int a=1;!f;a++){
            if(a%2==0||a%13==0)continue;
            for(int b=0;!f&&b<26;b++){
                char m[26];
                for(int i=0;i<26;i++)m[(i*a+b)%26]=i+'a';
                string t=str;
                for(int i=0;i<t.size();i++){
                    if(islower(t[i]))t[i]=m[t[i]-'a'];
                }
                bool f_this=(t.find("this")!=string::npos);
                bool f_that=(t.find("that")!=string::npos);
                if(f_this||f_that){
                    str=t;
                    f=true;
                }
            }
        }
        cout<<str<<endl;
    }
}

C++: #include<iostream>
#include<string>
#include<stdio.h>
int main(){
 string s;
 int n;
 cin>>n;
 for(int u=0;u<n;u++){
 getline(cin,s);
 int a=0;
 bool t=false;
 while(true){
  int b=0;
  while(true){
      for(int i=0;i<s.size();i++){
       if(isalpha(s[i])!=0)
        s[i]=(a*(s[i]-'a')+b)%26+'a';   
      }
      for(int i=0;i<s.size()-3;i++){
       if(s[i]=='t'&&s[i+1]=='h'&&s[i+2]=='i'&&s[i+3]=='s'){
       t=true;
       break;
       }
       if(s[i]=='t'&&s[i+1]=='h'&&s[i+2]=='a'&&s[i+3]=='t'){
       t=true;
       break;
       }
      }
      b++;
  }
  if(t==true)
  break;
  a++;
 }
 for(int i=0;i<s.size();i++)
 cout<<s[i];
 cout<<endl;
 }
 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;
    cin>>temp;
    getline(cin,y);
    for(int t=0; t<temp; t++){
        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]==' '){
                    x[i]=y[i];
                }else{
                    x[i]=affine[j][y[i]-'a']+'a';
                }
            }
        }
    
        
        
    }
    
    
    
    return 0;
}

C++: //============================================================================
// Name        : aoj0040.cpp
// Author      : afterCmidday
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <string>

using namespace std;


int gcd(int x,int y){
	if(y == 0){
		return x;
	}
	return gcd(y,x % y);
}
int main(void){
	int a = 3, b = 2, n, i, j;
	string str;
	cin >> n;
	getline(cin,str);
	for(i = 0;i < n;i++){
		getline(cin,str);
		for(j = 0;(unsigned int)j < str.size();j++){
			if(isalpha(str[j])){
				str[j] = ((str[j] - 'a') * a + b) % 26 + 'a';
			}
		}
		cout << str << endl;
	}
	return 0;
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>

typedef long long ll;
using namespace std;

int F(int a, int b, int c){
	return (a*c+b) % 26;
}

int main(){
	int n;
	string str1;
	getline(cin,str1);

	n = atoi(str1.c_str());
	for(int i=0;i<n;i++){
		string str2;
		getline(cin,str2);

		for(int a=0;a<100;a++){
			for(int b=0;b<100;b++){
				string tmp = str2;
				for(int i=0;i<str2.size();i++){
					if(tmp[i]=='.') continue;
					if(tmp[i]==' ') continue;
					if(isdigit(tmp[i])) continue;
					tmp[i] = F(a,b,str2[i]-'a') + 'a';
				}

				if(tmp.find("that") != string::npos
					|| tmp.find("this") != string::npos){
						cout << tmp << endl;
						goto found;
				}
			}
		}
found:;
	}
}

C++: #include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<numeric>
using namespace std;
const int dx[]={1,0,-1,0};
const int dy[]={0,1,0,-1};
#define INF 1e+8
#define EPS 1e-7
#define PB push_back
#define fi first
#define se second
#define ll long long
#define MOD 26
#define reps(i,j,k) for(int i = (j); i < (k); i++)
#define rep(i,j) reps(i,0,j)
typedef pair<int,int> Pii;
typedef vector<int> vi;
int main(){
	int n;
	scanf("%d",&n);
	while(n--){
		getchar();
		string str;
		getline(cin,str);
		string en = "abcdefghijklmnopqrstuvwxyz";
		string ans = "";
		rep(i,10000){
			if(i%26 == 0)continue;
			rep(j,1000){
				string sub;
				rep(k,str.size()){
					if(str[k] == ' ')sub += " ";
					else sub += en[((i*(str[k]-'a')+j) % MOD)];
				}
				rep(k,sub.size()-4){
					if(sub[k] == 't'&&sub[k+1] == 'h'&&sub[k+2] == 'i'&&sub[k+3] == 's'){
						ans = sub;
						goto end;
					}
					if(sub[k] == 't'&&sub[k+1] == 'h'&&sub[k+2] == 'a'&&sub[k+3] == 't'){
						ans = sub;
						goto end;
					}
				}
			}
		}
		end:;
		cout << ans << endl;
	}
	return 0;
}