n = gets.to_i
x = []
n.times do
  com, key = gets.split
  key = key.to_i
  case com
  when 'insert' then x.unshift key
  when 'delete'
    i = x.index(key)
    x.delete_at(i) unless i.nil?
  when 'deleteFirst' then x.shift
  when 'deleteLast' then x.pop
  end
end
puts x.join(' ')

