n = gets.chomp.to_i

list = []
n.times do
  p list
  command, x = gets.chomp.split
  
  p command
  case command
  when "insert"
    list.unshift x
  when "delete"
    if i = list.index(x)
      list.delete_at i
  when "deleteFirst"
    list.shift
  when "deleteLast"
    list.pop
  end
end

(list.size-1).times do |i|
  print "#{list[i]} "
end
print "#{list.last}\n"