N = int(eval(input()))

A = [0] * N

B = [0] * N

Sum = [[0] * 2 for i in range(N)]



for i in range(N):

    A[i], B[i] = list(map(int, input().split()))

    Sum[i][0] = i

    Sum[i][1] = A[i] + B[i]

    

a = 0

b = 0

turn = 0



Sum.sort(key=lambda x:x[1], reverse=True)

    

for i in range(N):

    if turn == 0:

        a += A[Sum[i][0]]

        turn = 1

    else:

        b += B[Sum[i][0]]

        turn = 0



print((a - b))
import sys

input = sys.stdin.readline



N = int(eval(input()))

A = [0] * N

B = [0] * N

Sum = [[0] * 2 for i in range(N)]



for i in range(N):

    A[i], B[i] = list(map(int, input().split()))

    Sum[i][0] = i

    Sum[i][1] = A[i] + B[i]

    

a = 0

b = 0

turn = 0



Sum.sort(key=lambda x:x[1], reverse=True)

    

for i in range(N):

    if turn == 0:

        a += A[Sum[i][0]]

        turn = 1

    else:

        b += B[Sum[i][0]]

        turn = 0



print((a - b))

N = int(eval(input()))
A = [0] * N
B = [0] * N
Sum = [[0] * 2 for i in range(N)]
for i in range(N):
    A[i], B[i] = list(map(int, input().split()))
    Sum[i][0] = i
    Sum[i][1] = A[i] + B[i]
a = 0
b = 0
turn = 0
Sum.sort(key=lambda x: x[1], reverse=True)
for i in range(N):
    if turn == 0:
        a += A[Sum[i][0]]
        turn = 1
    else:
        b += B[Sum[i][0]]
        turn = 0
print((a - b))

import sys

input = sys.stdin.readline
N = int(eval(input()))
A = [0] * N
B = [0] * N
Sum = [[0] * 2 for i in range(N)]
for i in range(N):
    A[i], B[i] = list(map(int, input().split()))
    Sum[i][0] = i
    Sum[i][1] = A[i] + B[i]
a = 0
b = 0
turn = 0
Sum.sort(key=lambda x: x[1], reverse=True)
for i in range(N):
    if turn == 0:
        a += A[Sum[i][0]]
        turn = 1
    else:
        b += B[Sum[i][0]]
        turn = 0
print((a - b))

+import sys + +input = sys.stdin.readline