import qualified Data.Vector.Unboxed as V
import qualified Data.ByteString.Char8 as BC
import Data.List(foldl', delete)
import Data.Maybe(fromJust)

main = BC.getContents >>= putStrLn.unwords.map show.V.toList.solve.map BC.words.tail.BC.lines

solve :: [[BC.ByteString]] -> V.Vector Int
solve = foldl' solve' (V.fromList [])
    where solve' xs (order:x) = case BC.unpack order of
                                  "deleteFirst" -> V.tail xs
                                  "deleteLast"  -> V.init xs
                                  "insert"      -> V.cons (readX x) xs
                                  "delete"      -> V.fromList.delete (readX x) $ V.toList xs
          readX = fst.fromJust.BC.readInt.head