Module P1
Sub main()

    Dim RD As String
    Dim SD() As String
    
    Dim N As Long
    Dim A() As Long
    Dim B() As Long
    Dim C() As Long
    Dim D() As Boolean
    Dim i As Long
    Dim j As Long
    
    Dim ManFlg As String
    
    Dim CMax As Long
    Dim AMax As Long
    Dim BMax As Long
        
    Dim AMaxIdx As Long
    Dim BMaxIdx As Long
    Dim CMaxIdx As Long
    Dim ASum As Long
    Dim BSum As Long
    
    N = Console.Readline()
    ReDim Preserve A(N - 1)
    ReDim Preserve B(N - 1)
    ReDim Preserve C(N - 1)
    ReDim Preserve D(N - 1)
    
    For i = 1 To N
        RD = Console.Readline()
        SD = Split(RD, " ")
        A(i - 1) = SD(0)
        B(i - 1) = SD(1)
         D(i - 1) = False
    Next
    
    ManFlg = "A"
    For j = 1 To N
        AMax = 0: AMaxIdx = 0: BMax = 0: BMaxIdx = 0
        If ManFlg = "A" Then
            For i = 1 To N
                If D(i - 1) = False Then
                    If A(i - 1) > AMax Then
                        AMax = A(i - 1)
                        AMaxIdx = i - 1
                    ElseIf A(i - 1) = AMax And B(i - 1) > BMax Then
                        BMax = B(i - 1)
                        AMaxIdx = i - 1
                    End If
                End If
            Next i
        Else
            For i = 1 To N
                If D(i - 1) = False Then
                    If B(i - 1) > BMax Then
                        BMax = B(i - 1)
                        BMaxIdx = i - 1
                    ElseIf B(i - 1) = BMax And A(i - 1) > AMax Then
                        AMax = A(i - 1)
                        BMaxIdx = i - 1
                    End If
                End If
            Next i
        End If
            
        If ManFlg = "A" Then
            ASum = ASum + A(AMaxIdx - 1)
            ManFlg = "B"
            D(AMaxIdx - 1) = True

        Else
            BSum = BSum + B(BMaxIdx - 1)
            ManFlg = "A"
            D(BMaxIdx - 1) = True
        
        End If
        
    Next
    
    Console.Writeline (ASum - BSum)

End Sub

end Module
