n = gets.chomp.to_i

a = []
n.times do
  inst, num = gets.chomp.split(" ")
  if inst == 'insert'
    a.unshift(num)
  elsif inst == 'delete'
    i = nil
    a.each do |aa|
      if aa == num
        i = a.index(aa)
        break
      else
        next
      end
    end
    if i
      a.delete_at(i)
    end
  elsif inst == 'deleteFirst'
    a.shift
  else
    a.pop
  end
end

puts a.join(" ")
