len = gets.to_i

array = []

len.times do |index|
    array.push(gets.chomp().split(" ").map{|n| n.to_i})
end

takahashi = []
aoki = []

while(true)
    # takahashi
    if array.all?{|n| array[0][0]==n[0] }
        array = array.sort{ |a, b| b[1] <=> a[1] }
    else
        array = array.sort{ |a, b| b[0] <=> a[0] }
    end
    takahashi.push(array.shift[0])
    if array==[]
        break
    end

    # aoki
    if array.all?{|n| array[0][1]==n[1] }
        array.sort{ |a, b| b[0] <=> a[0] }
    else
        array.sort{ |a, b| b[1] <=> a[1] }
    end
    aoki.push(array.shift[1])
    if array==[]
        break
    end
end



print((takahashi.reduce{|sum, n| sum+n}) - (aoki.reduce{|sum, n| sum+n}))
