n = gets.to_i
list = []

n.times do
  cmd, num = gets.split
  list.push(num) if cmd == "insert"
  list.delete(num) if cmd == "delete"
  list.delete(list[0]) if cmd == "deleteFirst"
  list.pop if cmd == "deleteLast"
end

puts list.reverse!.join(" ")