import scala.collection.mutable.ListBuffer
import scala.io.StdIn

object Main extends App {
  val n = StdIn.readInt()
  var list: ListBuffer[Int] = ListBuffer()
  for (i <- 1 to n) {
    val o = StdIn.readLine().split(" ").toList
    o.head match {
      case "insert" => list = o.last.toInt +: list
      case "delete" => list = list - o.last.toInt
      case "deleteFirst" => list = list.tail
      case "deleteLast" => list = list.slice(0, list.length - 1)
    }
  }
  println(list.mkString(" "))
}