#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"
vector<string> split(const string &str, char delim) {
	vector<string> res;
	size_t current = 0, found;
	while ((found = str.find_first_of(delim, current)) != string::npos) {
		res.push_back(string(str, current, found - current));
		current = found + 1;
	}
	res.push_back(string(str, current, str.size() - current));
	return res;
}
long long int gcd(long long int l, long long int r) {
	assert(l > 0 && r > 0);
	if (l > r)return gcd(r, l);
	else {
		const long long int num = r%l;
		if (num) {
			return gcd(l, num);
		}
		else {
			return l;
		}
	}
}
vector<int>tha{ 19,7,0,19 };
vector<int>thi{ 19,7,8,18 };

int main() {
	int N; cin >> N;
	string st;
	getline(cin, st);
	while (N--) {
		getline(cin, st);
		vector<string>sts(split(st, ' '));
		vector<vector<int>>numss(sts.size());
		for (int i = 0; i < sts.size(); ++i) {
			for (auto c : sts[i]) {
				numss[i].emplace_back(c - 'a');
			}
		}

		vector<vector<int>>finans;
		for (int a = 1; a < 26; ++a) {
			if (gcd(a, 26) != 1)continue;
			for (int b = 0; b < 26; ++b) {
				bool ok = false;
				vector<vector<int>>anss(numss);
				for (auto& nums : anss) {
					for (auto&num : nums) {
						num = (a*num + b) % 26;
					}
					if (nums == tha || nums == thi) {
						ok = true;
					}
				}
				if (ok)finans = anss;
			}
		}
		//finans.emplace_back(tha);
		for (int i = 0; i < finans.size(); ++i) {
			for (int j = 0; j < finans[i].size(); ++j) {
				cout << char(finans[i][j] + 'a');
			}
			if (i == finans.size() - 1)cout << endl;
			else cout << " ";
		}
	}
	return 0;
}