{-# LANGUAGE BangPatterns #-}

import           Control.Applicative
import           Control.Monad
import           Text.Printf

import           Data.Foldable       (toList)
import qualified Data.Sequence       as S

insert :: a -> S.Seq a -> S.Seq a
insert = (S.<|)

delete :: Eq a => a -> S.Seq a -> S.Seq a
delete x s
    | S.null r = s
    | otherwise =
        case S.viewl r of
            x S.:< xs -> l S.>< xs
  where
    (l, r) = S.breakl (== x) s

deleteFirst :: S.Seq a -> S.Seq a
deleteFirst s =
    case S.viewl s of
        x S.:< xs -> xs

deleteLast :: S.Seq a -> S.Seq a
deleteLast s =
    case S.viewr s of
        xs S.:> x -> xs

doCommands :: [[String]] -> [Int]
doCommands cs = toList $ f S.empty cs
  where
    f !s []                    = s
    f !s (["insert", a]:xss)   = f (insert (read a) s) xss
    f !s (["delete", a]:xss)   = f (delete (read a) s) xss
    f !s (["deleteFirst"]:xss) = f (deleteFirst s) xss
    f !s (["deleteLast"]:xss)  = f (deleteLast s) xss

main :: IO ()
main = do
    n <- readLn
    cs <- fmap words <$> replicateM n getLine
    let answer = doCommands cs
    putStrLn $ unwords $ fmap show answer

