import Control.Monad (replicateM_)
import Data.Char (ord,chr)
import Data.Array (array,bounds,inRange,(!))
import Data.List (isInfixOf)

main = do
    n <- readLn
    replicateM_ n (getLine >>= return . solve >>= putStrLn)

solve :: String -> String
solve s = head $ filter match $ map (\k -> decipher k s) keys
    where
    match s = ("this" `isInfixOf` s) || ("that" `isInfixOf` s)

keys :: [(Int,Int)]
keys = [(a,b)|a<-[1..25], gcd a 26 == 1, b<-[0..25]]

decipher :: (Int,Int) -> String -> String
decipher (a,b) = map decode
    where
    decode c
        | inRange (bounds table) c = table!c
        | otherwise = c

    table = array ('a','z') [(cipherLetter (a,b) c, c)|c<-['a'..'z']]

    cipherLetter (a,b) c = chr ((ord 'a') + (a * x + b) `mod` 26)
        where
        x = (ord c) - (ord 'a')