#include <iostream>
#include <string>
using namespace std;

void encode( const int a, const int b, string& s ){
	for ( unsigned i = 0; i < s.size(); ++i ){
		s[ i ] = static_cast< char >( ( ( s[ i ] - 'a' ) * a + b ) % 26 + 'a' );
	}
}

void decode( const int a, const int b, string& s ){
	string listA = "abcdefghijklmnopqrstuvwxyz", listB;
	for ( unsigned i = 0; i < listA.size(); ++i ){
		listB += static_cast< char >( ( ( listA[ i ] - 'a' ) * a + b ) % 26 + 'a' );
	}
	for ( unsigned i = 0; i < s.size(); ++i ){
		if ( !( s[ i ] >= a && s[ i ] <= 'z' ) ) continue;
		for ( unsigned j = 0; j < listB.size(); ++j ){
			if ( s[ i ] == listB[ j ] ){
				s[ i ] = listA[ j ];
				break;
			}
		}
	}
}

void identifyKeys( int& a, int& b, const string s ){
	for( a = 3; ; ++a ){
		if ( !( a % 2 ) || !( a % 13 ) ) continue;
		for ( b = 0; b < 26; ++b ){
			string sThis = "this", sThat = "that";
			encode( a, b, sThat );
			encode( a, b, sThis );
			if ( s.find( sThat ) != string::npos || s.find( sThis ) != string::npos ){
				return;
			}
		}
	}
}

int main(){
	string s, ws;
	int n;

	cin >> n;
	cin.ignore();

	for ( int i = 0; i < n; ++i ){
		getline( cin, s );
		int aKey = 0, bKey = 0;
		identifyKeys( aKey, bKey, s );
		decode( aKey, bKey, s );
		cout << s << endl;
	}

	return 0;
}