#include<iostream>
#include<stdio.h>
#include<string.h>

int main()
{
	int n;
	std::cin >> n;
	
	while( n-- ){
		char s[260], t[260];
		char a[29];
		
		fgets( s, 257, stdin );
		
		strcpy( t, s );
		
		for( int i = 1; i <= 26; i += 2 ){
			for( int j = 0; j < 26; j++ ){
				if( i % 13 == 0 ) continue;
				
 				for( int k = 0; k < 26; k++ ){
				 	a[ ( i * k + j ) % 26 ] = k + 'a';
				}
				
				for( int k = 0; k < strlen( t ); k++ ){
					if( s[k] == ' ' || s[k] == '\n' ) continue;
					
					s[k] = a[ t[k] - 'a' ];
				}
				
				if( strstr( s, "that" ) != NULL || strstr( s, "this" ) != NULL ){
					std::cout << s;
				}
				
				strcpy( s, t );
			}
		}
	}

 	return 0;
}