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<fstream>
#include<sstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdlib>
using namespace std;

#define ull unsigned long long
#define ll long long
#define PI 3.141592654

int module(int num){
	if(num > 0){
		return num%26;
	}	
	while(abs(num)>26)num +=26;
	return 26+num;
}

vector<string> that(string line){
	vector<string> word;
	int b = 0;
	string tmp = "";
	while(line[b] != 0){
		if(line[b] == ' '){
			word.push_back(tmp);
			tmp = "";
		}else{
			tmp += line[b];
		}
		b++;
	}

	if(tmp.size() > 0)word.push_back(tmp);
	vector<string> res;

	for(int x=0;x<word.size();++x){
		if(word[x].size()==4)res.push_back(word[x]);
	}
	return res;
}

int inv(int a){
	for(int x=1;x<26;++x){
		if((a*x)%26 == 1)return x;
	}
	return -1;
}

string solve(string org,int a,int b){
	string ret = "";
	for(int x=0;x<org.size();++x){
		if(org[x] == ' '){
			ret += " ";
		}else{
	//		cout<<a<<"#"<<inv(a)<<endl;
			ret += 'a' + (inv(a)*module(org[x]-b-'a'))%26;
		}
	}
	return ret;
}

int main(){
	int n;
	string line;
	while(getline(cin,line)){
		sscanf(line.c_str(),"%d",&n);
		for(int i=0;i<n;++i){
		 	getline(cin,line);
			vector<string> cand = that(line);
			bool flag = true;
			for(int c=0;c<cand.size() && flag;++c){
				for(int a=1;a<26 && flag;a+=2){
					int b = module(cand[c][0]-'a'-a*('t'-'a'));	
					string rta = solve(line,a,b);
	//				cout<<a<<":"<<b<<endl;
	//				cout<<rta<<endl;	
					if(rta.find("that")!=string::npos || rta.find("this")!=string::npos){
						cout<<rta<<endl;
						flag = false;
					}
				}
			}
		}
	}
	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);
				
		fgets(str,sizeof(str),stdin);
		
		
		for(int i=0;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;
					}
				}
			}
		}
	}
}

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 <string>

#define N 100
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;
}

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

#define N 100
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<iostream>
#include<string>
using namespace std;
int main(){
long i,j,k,n;
string s="that",t="this",ss;
cin>>n;getline(cin,ss);
for(;n>0;n--){
getline(cin,ss);
for(i=1;i<26;i+=2){
if(i==13)continue;
for(j=0;j<26;j++){
t[0]=t[3]=s[0]=(i*19+j)%26+97;
t[1]=s[1]=(i*7+j)%26+97;
t[2]=(i*0+j)%26+97;
s[2]=(i*8+j)%26+97;
s[3]=(i*18+j)%26+97;
if(ss.find(t)!=string::npos)goto L1;
if(ss.find(s)!=string::npos)goto L1;
}
}
L1:
if(i==3)i=9;
else if(i==5)i=21;
else if(i==7)i=15;
else if(i==9)i=3;
else if(i==11)i=19;
else if(i==15)i=7;
else if(i==17)i=23;
else if(i==19)i=11;
else if(i==21)i=5;
else if(i==23)i=17;
for(k=0;k<ss.size();k++)
if(96<ss[k]&&ss[k]<123)ss[k]=(i*(ss[k]-97+26-j))%26+97;
cout<<ss<<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;
	
	cin>>n;
	
	
	while(n--){
		flag=true;
		//改行がバッファに残っているので捨てる
		fflush(stdin);
				
		fgets(str,sizeof(str),stdin);
		
		
		for(int i=0;i<100;i++){
			if(gcd(i)==1){
				for(int j=0;j<26;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);
						goto Z;
					}
				}
			}
		}
		Z:;
	}
}

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;
	}
}