import Control.Applicative
import Control.Monad
import Data.List

main = do
  n <- readLn
  replicateM_ n $ getLine >>= mapM_ putStrLn.searchAffineSentence ["this","that"]

affinA :: [Int]
affinA = filter (\x -> gcd x 26 == 1) [1..25]
affinB :: [Int]
affinB = [0..25]

toChar :: Int -> Char
toChar n = ['a'..'z'] !! n
toInt  :: Char -> Int
toInt  c = length $ takeWhile (/= c) ['a'..'z']

decAff :: Int -> Int -> Int -> Int
decAff a b g = (a*g - a*b) `mod` 26

decodeAffineChar :: Int -> Int -> Char -> Char
decodeAffineChar a b c
  | c == ' ' = ' '
  | otherwise = toChar.decAff a b.toInt $ c

decodeAffineStr :: Int -> Int -> String -> String
decodeAffineStr a b = map (decodeAffineChar a b)


searchAffineSentence :: [String] -> String -> [String]
searchAffineSentence strs code = filter cond $ map (\(a,b) -> decodeAffineStr a b code) [(a,b) | a <- affinA, b <- affinB]
  where cond c = or ((map isInfixOf strs)<*>[c])