import Data.Maybe (fromMaybe)
import System.IO (isEOF)

main = do
    eof <- isEOF
    if eof then return ()
           else getLine >>= putStrLn.readNumLine.concatMap (toBin charCodeTable) >> main
--main = getContents >>= putStr.unlines.map (readNumLine.concatMap (toBin charCodeTable)).lines

toBin :: [(Char,String)] -> Char -> String
toBin list char = fromMaybe "" (lookup char list)
readNumLine :: String -> String
readNumLine (x:xs) = rnl [x] xs

rnl _   []   = []
rnl acc line = case lookup acc codeCharTable of
                 Just c -> c:readNumLine line
                 Nothing -> rnl (head line: acc) $ tail line



charCodeTable =  [('A',"00000"),('B',"00001"),('C',"00010"),('D',"00011")
                 ,('E',"00100"),('F',"00101"),('G',"00110"),('H',"00111")
                 ,('I',"01000"),('J',"01001"),('K',"01010"),('L',"01011")
                 ,('M',"01100"),('N',"01101"),('O',"01110"),('P',"01111")
                 ,('Q',"10000"),('R',"10001"),('S',"10010"),('T',"10011")
                 ,('U',"10100"),('V',"10101"),('W',"10110"),('X',"10111")
                 ,('Y',"11000"),('Z',"11001"),(' ',"11010"),('.',"11011")
                 ,(',',"11100"),('-',"11101"),('\'',"11110"),('?',"11111")]
codeCharTable = [("101",' '),("000000",'\''),("110000",','),("10001001",'-')
                 ,("100010",'.'),("100000",'?'),("101001",'A'),("01011001",'B')
                 ,("1010",'C'),("1000",'D'),("011",'E'),("10010",'F'),("11011001",'G')
                 ,("000010",'H'),("1110",'I'),("00011001",'J'),("0110",'K'),("00100",'L')
                 ,("10011001",'M'),("01111001",'N'),("10100",'O'),("111",'P')
                 ,("11111001",'Q'),("0001",'R'),("01100",'S'),("11100",'T'),("00111001",'U')
                 ,("10111001",'V'),("010000",'W'),("01001001",'X'),("11001001",'Y'),("00001001",'Z')]