n = gets.to_i

list = []
n.times{
  command = gets.split
  case command[0]
  when "insert"
    list.unshift(command[1])
  when "delete"
    tmp = []
    while list.size > 0 do
      it = list.shift
      break if it == command[1]
      tmp.push(it)
    end
    list = tmp + list
  when "deleteFirst"
    list.shift
  when "deleteLast"
    list.pop
  end
}
puts list.join(" ")