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>
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=j=99;
		}cout<<t<<endl;
	}return 0;
}

C++: #include<iostream>
#include<map>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>
#include<cmath>
using namespace std;
int inf = 1000000000;

int main(){

  int n;
  cin >> n;
  cin.ignore();
  bool f = true;
  for(int l=0; l<n; l++){
    string s;
    getline(cin, s); cin.ignore();

    for(int i=1; i<50&&f; i++){
      if( i % 2 == 0 || i % 13 == 0 ) continue;
      for(int j=1; j<50&&f; j++){
        string t = s;
        for(int k=0; k<s.size(); k++){
          if( 'a' <= t[k] && t[k] <= 'z' ) t[k]=(i*(t[k]-'a')+j)%26+'a';
        }
        if( t.find("that") != -1 || t.find("this") != -1 ){cout << t << endl; f = false; break;}
      }
    }

  }


  return 0;
}

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

#define N 1000
using namespace std;

main(){
  int n;
  string data[150];
  string tmp[150];
  cin >> n;
  for(int i=0;i<n;i++){
    int size;
    for(size=0;;size++){
      cin >> data[size];
      char c;
      scanf("%c", &c);
      if(c=='\n'){
	break;
      }
    }
    size++;
    for(int i=3;i<N;i+=2){
      if(i%13==0) continue;
      for(int j=0;j<N;j++){
	for(int k=0;k<size;k++){
	  tmp[k]="";
	}
	for(int a=0, b=0;a<size;b++){
	  if(data[a].size()<=b){
	    a++;
	    b=-1;
	    continue;
	  }
	  char c=(char)((i*(int)(data[a][b]-'a')+j)%26);
	  c+='a';
	  tmp[a]+=c;
	}
	for(int k=0;k<size;k++){
	  if(tmp[k]=="that" || tmp[k]=="this"){
	    for(int l=0;l<size;l++){
	      cout << tmp[l];
	      if(l==size-1) cout << endl;
	      else cout << ' ';
	    }
	    return 0;
	  }
	}
      }
    }
  }
  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][257]={};
	char str2[257][257]={};
	char *p;
	int ans,count=1;
	int flag=0;
	scanf("%d\n",&n);

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

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

string affine(string s, int a, int b) {
    string res = s;
    for(int i=0; i<res.size(); i++) {
        if(res[i]>='a' && res[i]<='z') {
            res[i] = ((res[i]-'a')*a + b)%26 + 'a';
        }
    }
    return res;
}

void solve() {
    string s, w;
    
    getline(cin, s);

    for(int a=1; a<26; a+=2) {
        if(a==13) continue;
        for(int b=0; b<26; b++) {
            w = affine(s, a, b);
            if(w.find("that")!=string::npos || w.find("this")!=string::npos) {
                cout << w << endl;
                return;
            }
        }
    }
}

int main() {
    string s;
    stringstream ss;
    int n;
    getline(cin, s);
    ss << s;
    ss >> n;

    for(int i=0; i<n; i++) {
        solve();
    }
}

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

vector<int> a;
vector<int> b;
int id=2;
int N;
int yukuri(int n,int m){
  if(n<m) swap(n,m);
  while(m>0){
    int tmp = n%m;
    n=m;
    m=tmp;
  }
  return n;
}

void add_ab(){
  ++id;
  while(yukuri(id,26)!=1) id++;
  for(int i=0;i<26;i++){
    a.push_back(id);
    b.push_back(i);
  }
}
int F(char y,int id){
  return ((int)(y-'a')*a[id]+b[id])%26;
}
string change(string s,int id){
  for(int i=0;i<(int)s.size()-1;i++){
    if(s[i]==' ') continue;
    s[i]=(char)F(s[i],id)+'a';
  }
  return s;
}

int main(){
  scanf("%d",&N);
  add_ab();
  for(int i=0;i<N;i++){
    char buf[258];
    getchar();
    fgets(buf,sizeof(buf),stdin);
    string s = buf;
    for(int i=0;i<(int)a.size();i++){
      s=change(s,i);
      if(0<=(int)s.find("that") || 0<=(int)s.find("this")){
	printf("%s",s.c_str());
	break;
      }
      //      printf("ng:: %s",s.c_str());
      s=buf;
      if(i==(int)a.size()-1){
	add_ab();
      }
    }
  }
}