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

doublyList :: [[String]] -> [Int]
doublyList cmds = U.toList $ foldl f vec cmds
  where
    vec = U.empty
    f vec ["insert", n] = U.cons (read n) vec
    f vec ["delete", n] = 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
  xs <- map words <$> replicateM n getLine
  let a = doublyList xs
  putStrLn $ unwords $ map show a

