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<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){
        string a,b;
        int q;
        cin>>q;
        while(getline(cin,a)){
            bool flg=0;
            b=a;
            for(int x=1;x<=26;x++){
                for(int y=1;y<=26;y++){
                    if(b.find("this")!=string::npos||b.find("that")!=string::npos){
                        cout<<b<<endl,flg=1;break;
                    }
                    else{

                        for(int i=0;i<a.length();i++){
                            if(a[i]>='a'&&a[i]<='z'){
                                b[i]=((((a[i]-'a')*x)+y)%26)+'a';
                            }
                        }
                    }
                }
                if(flg==1)break;
            }
        }
    return 0;
}

C++: #include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#define rep_to(a,i,n) for(i=a;i<n;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define rep_r(i,n) for(i=n-1;i>=0;i--)
#define debug_i(x) printf("x:%d\n",x)
#define debug_s(str) printf("str:%s\n",str)
#define debug_c(c) printf("c:%c\n",c) 

int main()
{
	int i,j,k,l,z;
	int n=0;
	char str[257]={};
	char str1[257][257]={};
	char str2[257][257]={};
	char *p;
	int ans,count=1;
	int flag=0;
	int len=0;
	scanf("%d\n",&n);

	rep(z,n)
	{
		fgets(str,sizeof(str),stdin);
		str[strlen(str)-1]='\0';
		i=0;
		j=0;
		k=0;
		rep(i,strlen(str))
		{
			if(str[i]==' ')
			{
				j++;
				k=0;
				i++;
				count++;
			}
			str1[j][k]=str[i];
			k++;
		}
		rep(k,count)
		{
			if(strstr(str1[k],"that")!=NULL)flag=2;
			else if(strstr(str1[k],"this")!=NULL)flag=2;
		}
		if(flag!=2)
		{
			while(1)
			{
				rep_to(1,j,26)
				{
					rep(k,count)
					{
						if(strstr(str2[k],"that")!=NULL)flag=1;
						else if(strstr(str2[k],"this")!=NULL)flag=1;
					}
					if(flag==1)break;
					rep(k,count)
					{
						rep(l,strlen(str1[k]))
						{
							str2[k][l]=(i*(str1[k][l]-97)+j)%26+97;
						}
					}
				}
				if(flag==1)break;
				i++;
			}
			rep(i,count)
			{
				rep(j,strlen(str2[i]))
				{
					if(len>=strlen(str))break;
					else 
					{
						printf("%c",str2[i][j]);
						len++;
					}
				}
				if(len>=strlen(str))break;
				else printf(" ");
				len++;
			}
			printf("\n");
		}
		else
		{
			rep(i,count)
			{
				if(count!=i)printf("%s ",str1[i]);
				else printf("%s",str1[i]);
			}
			printf("\n");
		}
		
		flag=0;
		rep(i,strlen(str))str[i]='\0';
		rep(i,count)rep(j,strlen(str2[i]))str2[i][j]='\0';
		rep(i,count)rep(j,strlen(str1[i]))str1[i][j]='\0';
		count=1;
		i=0;
		len=0;
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>

int gcd(int a, int b){
	return (b>0?gcd(b,a%b):a);
}

int extgcd(int a, int b, int& x, int& y){
	int d = a;
	if(b != 0){
		d = extgcd(b, a%b, y, x);
		y -= (a/b) * x;
	}else{
		x = 1; y = 0;
	}
	return d;
}

int mod_inverse(int a, int m){
	int x, y;
	extgcd(a, m, x, y);
	return (m + x % m) % m;
}

int main(){
	int n;
	std::cin >> n;
	std::cin.ignore();
	for(;n--;){
		std::string s;
		std::getline(std::cin, s);
		for(int a=1;a<26;a++){
			if(gcd(a, 26) != 1)continue; //素ではない(1,26だと素なんですね)
			int b = 0;
			for(;b<26;b++){
				std::string new_s = s;
				int inverse_a = mod_inverse(a, 26);
				std::transform(new_s.begin(), new_s.end(), new_s.begin(),
											 [inverse_a, b](char c){
												 if(c < 'a' || c > 'z')return c;
												 int x = c - 'a';
												 int new_x = inverse_a * (x>b?x-b:x-b+26) % 26;
												 return static_cast<char>(new_x + 'a');
											 });
				if(new_s.find("this") != std::string::npos ||
					 new_s.find("that") != std::string::npos){
					std::cout << new_s << std::endl;
					break;
				}
			}
			if(b < 26){break;}
		}
	}
}

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

string ss, subs[256];
int a, b, n;

bool ifincluded(string trg, string s){
    int count = 0;
    string::iterator ittrg = trg.begin();
    for(string::iterator its = s.begin(); its != s.end(); its++){
        if( *its == *ittrg ){
            ittrg++;
            if( ittrg == trg.end() ){
                return 1;
            }
        }else{
            ittrg = trg.begin();
            if( its == trg.begin() ){
                ittrg++;
            }
        }

    }
    return false;
}

int main(){
    cin >> n;
    getline(cin, ss);
    string THIS("this"), THAT("that");
    while( n-- > 0 ){
        getline(cin, ss);
        string cs;
        bool ok = false;
        for(a = 1; !ok && a < 26; a++){
            if( 26%a == 0 ) continue;
            for(b = 0; !ok && b < 26; b++){
                cs = ss;
                for(string::iterator it = cs.begin(); it != cs.end(); it++){
                    if( isalpha( *it ) ){
                        *it = ( (*it-'a') * a + b) % 26 + 'a'; 
                    }
                }
                if( ifincluded( THIS, cs ) ||
                    ifincluded( THAT, cs ) ){
                    ok = 1;
                }
            }
        }
        cout << cs << endl;
    }
    return 0;
}

C++: #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 999999999
#define eps 1e-9


bool solve(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;
    cin.ignore();
    rep(i,n){
        string s;
        getline(cin,s);
        rep(j,1000){
            rep(k,27){
                string m=s;
                rep(l,m.size()){
                    if(isalpha(m[l])){
                        m[l] = 'a'+((j*(m[l]-'a')+k)%26);
                    }
                }
//                cout<<m<<endl;
                if(solve(m)){
                    cout<<m<<endl;
                    goto end;
                }
            }
        }
    end:;
    }
}

C++: #include<iostream>
#include<string>
using namespace std;
#define A 12
int main()
{
  int n,i,j;
  int alpha[A]={3,5,7,9,11,13,15,17,19,21,23,25},beta;
  string s,t;
  bool f;
  getline(cin,s);
  while(getline(cin,s)){
    f=true;
    for(i=0;f && i<A;i++){
      for(beta=0;f && beta<26;beta++){
	t=s;
	for(j=0;j<t.size();j++){
	  if(t[j]==' ')continue;
	  t[j]-='a';
	  t[j]=(t[j]*alpha[i]+beta)%26;
	  t[j]+='a';
	}
	if(t.find("this")!=string::npos)f=false;
	if(t.find("that")!=string::npos)f=false;
      }
    }
    cout<<t<<endl;
  }
}