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

size = 2 * 10^6

doublyLinkedList :: [(String, Int)] -> IO (U.Vector Int)
doublyLinkedList cmds = do
  vec <- UM.new size
  (f, r) <- loop vec (size - 1) (size - 1) cmds
  U.freeze (UM.slice (f + 1) (r - f) vec)
    where
      loop _ f r [] = return (f, r)
      loop vec f r (("insert", n) : cmds) = do
        UM.write vec f n
        loop vec (f - 1) r cmds
      loop vec f r (("delete", n) : cmds) = do
        del vec (f + 1) r n
        loop vec (f + 1) r cmds
      loop vec f r (("deleteFirst", _) : cmds) = loop vec (f + 1) r cmds
      loop vec f r (("deleteLast", _) : cmds)  = loop vec f (r - 1) cmds

      del vec f r n = do
        i <- find vec f r n
        when (i >= 0) $ do
          del' vec f i
            where
              find vec i r n = if i > r
                               then return (-1)
                               else do
                v <- UM.read vec i
                if v == n
                  then return (i)
                  else find vec (i + 1) r n
              del' vec s e = forM_ [e, e - 1 .. s] $ \i -> do
                v <- UM.read vec (i - 1)
                UM.write vec i v

toTuple :: [String] -> (String, Int)
toTuple [s] = (s, 0)
toTuple [s, n] = (s, read n)

main :: IO ()
main = do
  n  <- readLn
  xs <- map (toTuple . words) <$> replicateM n getLine
  a <- doublyLinkedList xs
  putStrLn $ unwords $ map show $ U.toList a

