import Data.List

main :: IO ()
main = getLine >> getContents >>= putStrLn.unwords.map show.foldl' (flip ($!)) [].map parse.lines

parse :: String -> ([Int] -> [Int])
parse "deleteFirst"    = tail
parse "deleteLast"     = init
parse str              = let [order, x] = words str
                         in case order of
                            "insert" -> ((read x) :)
                            "delete" -> delete (read x)