import qualified Data.Vector.Unboxed as U
import Control.Applicative
import Control.Monad

doublyList :: U.Vector Int -> [String] -> U.Vector Int
doublyList vec cmd = f vec cmd
  where
    f vec ["insert", n] = U.cons (read n) vec
    f vec ["delete", n] = if (U.null bs) then as else as U.++ (U.tail bs)
      where (as, bs) = U.break (== (read n)) vec
    f vec ["deleteFirst"] = U.tail vec
    f vec ["deleteLast"]  = U.init vec

main :: IO ()
main = do
  n  <- readLn
  let vec = U.empty
  loop n vec
    where
      loop 0 vec = putStrLn $ unwords $ map show $ U.toList vec
      loop i vec = do
        cmd <- words <$> getLine
        loop (i - 1) (doublyList vec cmd)

