import Data.List  -- isPrefixOf

table1 = zip (['A'..'Z'] ++ " .,-'?") (binaryStr 5)
binaryStr 0 = [""]
binaryStr n = map ('0':) bs ++ map ('1':) bs
  where  bs = binaryStr (n - 1)

table2 = zip (" ',-.?" ++ ['A'..'Z'])
  (words ("101 000000 000011 10010001 010001 000001 100101 10011010 " ++
          "0101 0001 110 01001 10011011 010000 0111 10011000 " ++
          "0110 00100 10011001 10011110 00101 111 10011111 1000 " ++
          "00110 00111 10011100 10011101 000010 10010010 10010011 10010000"))

encode tbl str = concat $ map (replaceBy tbl) str
replaceBy tbl c = snd . head $ dropWhile ((/= c) . fst) tbl

decode tbl str
  | c == '/'   = []
  | otherwise  = c : decode tbl rest
  where (c,rest) = replacePrefixBy tbl str

replacePrefixBy tbl str = (c, drop (length bin) str)
  where (c,bin) = head $ dropWhile (not . (`isPrefixOf` str) . snd) tbl'
        tbl' = tbl ++ [('/', str)]  -- a sentinel

main = do
  s <- getContents
  putStr . unlines . map (decode table2 . encode table1) . lines $ s