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<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<stack>
#include<cmath>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)



int main(){
	
	string sss;
	getline(cin,sss);
	
	while(1){
		string a;
		getline(cin,a);
		if(cin.eof())break;
		
		reps(alpha,2,100){
			reps(beta,2,100){
				
				bool ok = true;
				map<int,int> visit;
				rep(j,26){
					int next = (j*alpha+beta)%26;
					if(visit[next]==0){
						visit[next]=1;
					}else{
						ok=false;
					}
				}
				if(!ok)continue;
				
				string b;
				rep(j,a.size()){
					if('a'<=a[j]&&a[j]<='z')b+=((a[j]-'a')*alpha+beta)%26+'a';
					else b+=a[j];
				}
				if(b.find("this")!=-1 || b.find("that")!=-1){
					cout<<b<<endl;
					goto A;
				}
			}
		}
		A:;
	}
}

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

int GCD(int a, int b){
	return (b == 0) ? a:GCD(b, a%b);
}

char affine(int a, int b, char ch){
	int y = (int)(ch - 'a');
	return (char)((a*y+b)%26) + 'a';
}

int main(){
	bool ok;
	string str;
	getline(cin, str);
	while (getline(cin, str)) {
		ok = false;
		for (int a = 1; a < 100 && !ok; a++) {
			if(GCD(a, 26) != 1){
				continue;
			}
			for (int b = 0; b < 26 && !ok; b++) {
				for (int j = 0; j < str.size(); j++) {
					if('a' <= str[j] && str[j] <= 'z'){
						str[j] = affine(a, b, str[j]);
					}
				}
				if(str.find("that") != string::npos || str.find("this") != string::npos){
					cout << str << endl;
					ok = true;
				}
			}
		}
	}
	return 0;
}

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

int affine(int m, int a, int b){
  return (m * a + b) % 26;
}

int main(void){
  int n;
  string c, p;
  cin >> n; cin.ignore();
  
  while(n--){
    bool finded = false;
    getline(cin, c); p = c;
    for(int a = 1; a < 100; a++){
      if(finded) break;
      for(int b = 1; b < 26; b++){
        for(int i = 0; i < p.size(); i++){
          if(c[i] != ' ') p[i] = (char)(affine(c[i] - 'a', a, b) + 'a');
        }
        
        if(p.find("this") != string::npos || p.find("that") != string::npos){
          cout << p << endl;
          finded = true;
          break;
        }
      }
    }
  }
  return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
using namespace std;
	
char F(int alpha,int beta,char c){
	return 'a'+(alpha*(c-'a')+beta)%26;
}
int gcd(int a,int b){
	return b==0?a:gcd(b,a%b);
}
int main(){
	int n;
	string in,s,ans;
	cin>>n;
	getline(cin,in);
	while(n--){
		getline(cin,in);
		for(int i=1;i<26;i++){
			if(gcd(26,i)!=1)continue;
			for(int j=0;j<26;j++){
				s.resize(in.size());
				for(int k=0;k<in.size();k++){
					if(in[k]==' ')s[k]=' ';
					else s[k]=F(i,j,in[k]);
				}
				if(s.find("that",0)!=string::npos
					|| s.find("this",0)!=string::npos){
					cout<<s;
					return 0;
				}
			}
		}
	}
	return 0;
}

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

string THIS = "this", THAT = "that";
int gcd(int a, int b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}
int main() {
	int a;
	string b;
	cin >> a;
	getline(cin, b);
	for (int c = 0; c < a; c++) {
		getline(cin, b);
		for (int d = 1; d < 26; d++) {
		l:;
			for (int e = 0; e < 26; e++) {
				if (gcd(d, 26) != 1)continue;
				string s;
				for (int f = 0; f < b.length(); f++) {
					if (b[f] == ' ')s += ' ';
					else {
						for (int g = b[f] - 'a';g<26*26+'a'; g += 26) {
							if ((g - e) % d == 0 && (g - e) / d >= 0 && (g - e) / d < 26) { s += ((g - e) / d + 'a'); goto r; }
						}
						goto l;
					r:;
					}
				}
				for (int i = 0; i < s.length() - 4; i++) {
					bool x = true, y = true;
					for (int p = 0; p < 4; p++) {
						if (s[i + p] != THIS[p])x = false;
						if (s[i + p] != THAT[p])y = false;
					}
					if (x | y) { cout << s << endl; break; }
				}
			}
		}
	}
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cstdio>
#include <sstream>

using namespace std;

string check(string str);
map<char, int> create_table();

int main(){
  char ch = 'a';
  string str;
  int num;
  vector<string> answers;
  map<char,int> table = create_table();
  cin >> num;

  cin.ignore();
  for(int k=0; k<num; k++){
    getline(cin, str);

    char c;
    char list[1];
    bool flag = true;
    int beta;
    int alpha = 1;
    map<char, int>::iterator itr;
    while(flag){
      for(beta=1; beta<26; beta++){
        string result;
        for(int i=0; i<str.size(); i++){
          c = str[i];
          if(c != ' '){
            sprintf(list, "%c", ch+(19*table[c]+20)%26);
            result += list[0];
          }else{
            result += ' ';
          }
        }
        if(result.find("this",0) !=string::npos || result.find("that",0) != string::npos){
          answers.push_back(result);
          flag = false;
          break;
        }
      }
      alpha++;
    }
  }

  for(int j=0; j<answers.size(); j++){
    cout << answers[j] << endl;
  }
  return 0;
}


map<char, int> create_table(){
  map<char, int> table;
  char ch[1];
  char str = 'a';

  for(int i=0; i<26; i++){
    sprintf(ch, "%c", str+i); 
    table.insert(pair<char,int>(ch[0],i));
  }
  return table;
}

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

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

int main()
{
  int N;
  string str;
  cin >> N;
  cin.ignore();
  //printf("N = %d\n", N);
  for (int i = 0; i < N; i++) {
    if (i == 0) getline(cin, str);
    getline(cin, str);

    istringstream is(str);
    string tmp;
    vector<string> token;
    while (is >> tmp) {
      token.push_back(tmp);
    }
    /*for (int j = 0; j < token.size(); j++) {
      cout << token[j] << endl;
      }*/

    for (int a = 0; a < 26; a++) {
      for (int b = 0; b < 26; b++) {
	for (int j = 0; j < token.size(); j++) {
	  tmp = token[j];
	  for (int k = 0; k < token[j].size(); k++) {
	    tmp[k] = decode(a, b, tmp[k]);
	  }
	  if (tmp == "this" || tmp == "that") {
	    for (int k = 0; k < token.size(); k++) {
	      for (int l = 0; l < token[k].size(); l++) {
		cout << decode(a, b, token[k][l]);
	      }
	      if (k == token.size() - 1) {
		cout << endl;
		goto next;
	      } else {
		cout << " ";
	      }
	    }
	  }
	}
      }
    }
  next:;
  }
}

C++: #include<iostream>
#include<string>
using namespace std;
int trans[26];
void makelist(int a,int b){
for(int i=0;i<26;i++){
trans[i]=(a*i+b)%26;
}
}
string translate(string s){
for(int i=0;i<s.size();i++){
if(s[i]>='a' && s[i]<='z'){
s[i]=trans[s[i]-'a']+'a';
}
}
return s;
}
int main(){
//a!=2,13 **
int n;
cin>>n;
cin.ignore();
for(int count=0;count<n;count++){
string s;
getline(cin,s);
string tmp=s;
int a=0,b=100;
while(s.find("that")==string::npos && s.find("this")== string::npos){
b++;
if(b>=26){
b=0;
a++;
}
while(a%2==0||a%13==0)a++;
makelist(a,b);
s=translate(tmp);
//cout<<s<<endl;
}
cout<<s<<endl;
}
}