dec1 [] = []
dec1 (s:sx) = 
  let d = case s of
            'A' -> [0,0,0,0,0]
            'B' -> [0,0,0,0,1]
            'C' -> [0,0,0,1,0]
            'D' -> [0,0,0,1,1]
            'E' -> [0,0,1,0,0]
            'F' -> [0,0,1,0,1]
            'G' -> [0,0,1,1,0]
            'H' -> [0,0,1,1,1]
            'I' -> [0,1,0,0,0]
            'J' -> [0,1,0,0,1]
            'K' -> [0,1,0,1,0]
            'L' -> [0,1,0,1,1]
            'M' -> [0,1,1,0,0]
            'N' -> [0,1,1,0,1]
            'O' -> [0,1,1,1,0]
            'P' -> [0,1,1,1,1]
            'Q' -> [1,0,0,0,0]
            'R' -> [1,0,0,0,1]
            'S' -> [1,0,0,1,0]
            'T' -> [1,0,0,1,1]
            'U' -> [1,0,1,0,0]
            'V' -> [1,0,1,0,1]
            'W' -> [1,0,1,1,0]
            'X' -> [1,0,1,1,1]
            'Y' -> [1,1,0,0,0]
            'Z' -> [1,1,0,0,1]
            ' ' -> [1,1,0,1,0]
            '.' -> [1,1,0,1,1]
            ',' -> [1,1,1,0,0]
            '-' -> [1,1,1,0,1]
            '\''-> [1,1,1,1,0]
            '?' -> [1,1,1,1,1]
  in
    d++(dec1 sx)

dec2 (0:0:0:1:y)         = 'D':(dec2 y)
dec2 (0:0:1:0:0:y)       = 'L':(dec2 y)
dec2 (0:0:1:0:1:y)       = 'O':(dec2 y)
dec2 (0:0:1:1:0:y)       = 'S':(dec2 y)
dec2 (0:0:1:1:1:y)       = 'T':(dec2 y)
dec2 (0:0:0:0:0:0:y)     = '\'':(dec2 y)
dec2 (0:0:0:0:1:1:y)     = ',':(dec2 y)
dec2 (0:0:0:0:0:1:y)     = '?':(dec2 y)
dec2 (0:0:0:0:1:0:y)     = 'W':(dec2 y)
dec2 (0:1:0:0:0:0:y)     = 'H':(dec2 y)
dec2 (0:1:0:0:0:1:y)     = '.':(dec2 y)
dec2 (0:1:0:0:1:y)       = 'F':(dec2 y)
dec2 (0:1:0:1:y)         = 'C':(dec2 y)
dec2 (0:1:1:1:y)         = 'I':(dec2 y)
dec2 (1:0:0:0:y)         = 'R':(dec2 y)
dec2 (1:0:0:1:0:0:0:0:y) = 'Z':(dec2 y)
dec2 (1:0:0:1:0:0:0:1:y) = '-':(dec2 y)
dec2 (1:0:0:1:0:0:1:0:y) = 'X':(dec2 y)
dec2 (1:0:0:1:0:0:1:1:y) = 'Y':(dec2 y)
dec2 (1:0:0:1:0:1:y)     = 'A':(dec2 y)
dec2 (1:0:0:1:1:0:0:0:y) = 'J':(dec2 y)
dec2 (1:0:0:1:1:0:0:1:y) = 'M':(dec2 y)
dec2 (1:0:0:1:1:0:1:0:y) = 'B':(dec2 y)
dec2 (1:0:0:1:1:0:1:1:y) = 'G':(dec2 y)
dec2 (1:0:0:1:1:1:0:0:y) = 'U':(dec2 y)
dec2 (1:0:0:1:1:1:0:1:y) = 'V':(dec2 y)
dec2 (1:0:0:1:1:1:1:0:y) = 'N':(dec2 y)
dec2 (1:0:0:1:1:1:1:1:y) = 'Q':(dec2 y)
dec2 (1:0:1:y)           = ' ':(dec2 y)
dec2 (1:1:0:y)           = 'E':(dec2 y)
dec2 (1:1:1:y)           = 'P':(dec2 y)
dec2 _ = []

ans s =
  let d1 = dec1 s
      d2 = dec2 d1
  in
    d2

main = do
  c <- getContents
  let l = lines c
      o = map ans l
  mapM_ putStrLn o