$list = []

def insert(x)
  $list.insert 0, x
end

def delete(x)
  $list.delete_at $list.index(x) unless $list.index(x).nil?
end

def deleteFirst
  $list.delete_at 0
end

def deleteLast
  $list.delete_at(-1)
end

n = gets.to_i
n.times do
  input = gets.split ' '
  value = input[1].to_i
  case input[0]
  when 'insert'
    insert value
  when 'delete'
    delete value
  when 'deleteFirst'
    deleteFirst
  when 'deleteLast'
    deleteLast
  end
end

puts $list.join ' '

