#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <sstream>
 
#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
	int n;
	std::vector<int> alpha_vec;
	std::string buf;

	alpha_vec.push_back(1);
	alpha_vec.push_back(3);
	alpha_vec.push_back(5);
	alpha_vec.push_back(7);
	alpha_vec.push_back(9);
	alpha_vec.push_back(11);
	alpha_vec.push_back(15);
	alpha_vec.push_back(17);
	alpha_vec.push_back(19);
	alpha_vec.push_back(21);
	alpha_vec.push_back(23);
	alpha_vec.push_back(25);

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	std::cin.rdbuf(ifs.rdbuf());
#endif

	std::cin >> n;
	std::getline(std::cin, buf);
	
	for(int i = 0; i < n; i++){
		std::getline(std::cin, buf);
		for(int j = 0; j < alpha_vec.size(); j++){
			int alpha = alpha_vec[j];
			for(int beta = 0; beta < 26; beta++){
				std::map<unsigned char, unsigned char> map;
				std::string decoded_buf = buf;

				for(unsigned char k = 0; k <= 25; k++){
					unsigned char f = (alpha * k + beta) % 26;
					map[f + 'a'] = k + 'a';
				}
				
				for(int k = 0; k < decoded_buf.size(); k++){
					if(decoded_buf[k] >= 'a' && decoded_buf[k] <= 'z'){
						decoded_buf[k] = map[decoded_buf[k]];
					}
				}
				if(decoded_buf.find("that") != std::string::npos ||
					decoded_buf.find("this") != std::string::npos){
					std::cout << decoded_buf << std::endl;
				}
			}
		}

	}


#if INPUT_FROM_FILE
		//fclose(fp);
#endif
	return 0;
}

