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,a[12] = {1,3,5,7,9,11,15,17,19,21,23,25};
  cin >>n;
  cin.ignore();
  while(n--){
    string s;
    getline(cin,s);
    for(int i=0; i<12; i++){
      for(int j=0; j<26; j++){
	string f = s;
	for(int k=0; k<s.size(); k++){
	  if(f[k] >= 'a' && f[k] <= 'z'){f[k] = (a[i]*(f[k]-'a')+j)%26+'a';}
	}
	string::size_type pos_this = f.find("this");
	string::size_type pos_that = f.find("that");
	if(pos_this != string::npos){cout <<f<<endl;}
	if(pos_that != string::npos){cout <<f<<endl;}
      }
    }
  }
  return 0;
}

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

using namespace std;


int main() {

  int n;
  string buf;

  string word[300];
  string n_word[300];

  char* tp;
  int idx;
  bool flag;

  cin >> n;

  getline(cin,buf);

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

    getline(cin,buf);

    idx=0;

    tp=strtok((char*)buf.c_str()," ");

    for(int j=0;tp!=NULL;j++) {

      word[j]=tp;

      idx++;
      //cout << word[j] << " ";
      tp=strtok(NULL," ");

    }

    //cout << word[2][1] << " " << word[0].size();

    flag=false;

    for(int i=0;i<26;i++) {

      if(i%2==0 || i==13) continue;

      else {

	for(int j=0;j<26;j++) {

	  for(int k=0;k<idx;k++) n_word[k]="";

	  for(int k=0;k<idx;k++) {

	    for(int l=0;l<word[k].size();l++) {

	      n_word[k]+=(i*(word[k][l]-'a')+j)%26+'a';

	    }

	    if(n_word[k]=="this" || n_word[k]=="that") {

	      flag=true;

	    }

	  }

	  if(flag==true) goto Next;

	}

      }

    }

  Next:
    for(int i=0;i<idx;i++) {

      if(i==0) cout << n_word[i];
      
      else cout << " " << n_word[i];

    }

    cout << endl;

  }      

  return 0;

}

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

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

int main(void)
{
	int n;
	string a;
	getline(cin, a);
	
	n = atoi(a.c_str());
	for (int i = 0; i < n; i++){
		// cout << "*" << endl;
		string str;
		getline(cin, str);
		
		for (int a = 0; a < 100; a++){
			for (int b = 0; b < 100; b++){
				string tmp = str;
				for (int j = 0; j < str.size(); j++){
						if (tmp[j] == '.') continue;
						if (tmp[j] == ' ') continue;
						if (isdigit(tmp[j])) continue;
						tmp[j] = func(a, b, str[j] - 'a') + 'a';
				}
				
				if (tmp.find("that") != string::npos || tmp.find("this") != string::npos){
					cout << tmp << endl;
					goto a;
				}
			}
		}
	}
	
	a:;
	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 main(){
	int n;
	string in,s,ans;
	cin>>n;
	getline(cin,in);
	while(n--){
		getline(cin,in);
		for(int i=1;i<26;i++){
			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<<endl;
					return 0;
				}
			}
		}
	}
	return 0;
}

C++: #include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
using namespace std;

int main() {

    string cip;
    getline(cin, cip);

    while(getline(cin, cip)) {
        bool hit = false;
        for(int a = 1; a < 26; a++) {
            if ( a % 2 == 0 || a == 13 )    continue;
            for(int b = 0; b < 26; b++) {
                string test = cip;
                for(int c = 0; c < cip.length(); c++) {
                    if ( cip[c] != ' ' ) test[c] = ((cip[c] - 'a') * a + b) % 26 + 'a';
                }
                if ( test.find("this") != string::npos || test.find("that") != string::npos ) {
                    hit = true;
                    cip = test;
                    break;
                }
            }
            if(hit) break;
        }
        cout << cip << endl;
    }

    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int n, s;

int Comb(int N, int start, int s)
{
	int ret = 0;

	if (s < 0)
		return 0;

	if (N == n)
		if (start == s)
			return 1;
		else
			return 0;

	for (int i = start + 1; i <= 9; ++i)
		ret += Comb(N + 1, i, s - start);
	return ret;
}

int main(){

	vector<int> RET;
	while (cin >> n >> s && (n != 0 || s != 0))
	{
		int ret = 0;
		for (int i = 0; i <= 9; ++i)
			ret += Comb(1, i, s);
		RET.push_back(ret);
	}
	for (int i = 0; i < RET.size(); i++) {
		cout << RET[i] << endl;
	}
	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 {
						char c;
						for(c='a';;c++){
							if(F(i,j,c)==in[k])
								break;
						}
						s[k]=c;
					}
				}
				if(s.find("that",0)!=string::npos
					|| s.find("this",0)!=string::npos){
					cout<<s;
					return 0;
				}
			}
		}
	}
	return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <sstream>
#include <istream>
#include <cmath>
#include <cstdio>

using namespace std;

#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapii map<int, int>
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()
#define minit(a, i) memset(a, i, sizeof(a));

#define for_(i, a, b) for (int i=(int)a; i<(int)b; i++)
#define for_d(i, a, b) for (int i=(int)a-1; i>=b; i--)
#define for_r(i, a, b, c) for (int i=(int)a; i<(int)b; i += c)
#define for_dr(i, a, b, c) for (int i=(int)a-1; i>=b; i -= c)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

typedef long long ll;

const int iINF = 2147483647;
const ll lINF = 9223372036854775807;

template <class T> inline void dbg(T t) { cout << t << endl; }




vcs splitAll(string s, string t) {
	vcs r;
	for (int p = 0; (p = s.find(t)) != s.npos;) {
		r.pb(s.substr(0, p));
		s = s.substr(p + t.size());
	}
	r.pb(s);
	return r;
}

char func(char c) {
	int t = ('c'-'a' - 2)%26;
	char ret = 'a' + t;
	return ret;
}

vcs convert(vcs v) {
	vcs ret;
	int m = (int)v.sz;
	
	for_(i, 0, m) {
		string s = v[i];
		int len = (int)s.sz;
		for_(j, 0, len) s[i] = func(s[i]);
		ret.pb(s);
	}
}

int main() {
	int n; cin >> n;
	
	for_(i, 0, n) {
		string in;
		getline(cin, in);
		
		vcs v = splitAll(in, " ");
		vcs ret = convert(v);
		
		int m = (int)ret.sz;
		for_(j, 0, m-1) cout << ret[j] << " ";
		cout << ret[m-1] << endl;
	}
	
	return 0;
}