from heapq import heapify, heappush, heappop



N = int(eval(input()))

As, Bs = [], []

for _ in range(N):

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

    As.append(A)

    Bs.append(B)



PQ = [(-A-B, i) for i, (A, B) in enumerate(zip(As, Bs))]

heapify(PQ)



t = 1

hT = hA = 0

while PQ:

    H, i = heappop(PQ)

    if t % 2:

        hT += As[i]

    else:

        hA += Bs[i]

    t += 1



print((hT - hA))

N = int(eval(input()))

As, Bs = [], []

for _ in range(N):

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

    As.append(A)

    Bs.append(B)



Cs = [(A+B, i) for i, (A, B) in enumerate(zip(As, Bs))]

Cs.sort(reverse=True)



hA = sum([As[i] for C, i in Cs[::2]])

hB = sum([Bs[i] for C, i in Cs[1::2]])

print((hA - hB))

from heapq import heapify, heappush, heappop

N = int(eval(input()))
As, Bs = [], []
for _ in range(N):
    A, B = list(map(int, input().split()))
    As.append(A)
    Bs.append(B)
PQ = [(-A - B, i) for i, (A, B) in enumerate(zip(As, Bs))]
heapify(PQ)
t = 1
hT = hA = 0
while PQ:
    H, i = heappop(PQ)
    if t % 2:
        hT += As[i]
    else:
        hA += Bs[i]
    t += 1
print((hT - hA))

N = int(eval(input()))
As, Bs = [], []
for _ in range(N):
    A, B = list(map(int, input().split()))
    As.append(A)
    Bs.append(B)
Cs = [(A + B, i) for i, (A, B) in enumerate(zip(As, Bs))]
Cs.sort(reverse=True)
hA = sum([As[i] for C, i in Cs[::2]])
hB = sum([Bs[i] for C, i in Cs[1::2]])
print((hA - hB))

-from heapq import heapify, heappush, heappop - -PQ = [(-A - B, i) for i, (A, B) in enumerate(zip(As, Bs))] -heapify(PQ) -t = 1 -hT = hA = 0 -while PQ: -    H, i = heappop(PQ) -    if t % 2: -        hT += As[i] -    else: -        hA += Bs[i] -    t += 1 -print((hT - hA)) +Cs = [(A + B, i) for i, (A, B) in enumerate(zip(As, Bs))] +Cs.sort(reverse=True) +hA = sum([As[i] for C, i in Cs[::2]]) +hB = sum([Bs[i] for C, i in Cs[1::2]]) +print((hA - hB))