N = int(eval(input()))

l = []

sumB = 0

for i in range(N):

    tmp = list(map(int, input().split()))

    l.append(tmp[0] + tmp[1])

    sumB += tmp[1]

l.sort(reverse=True)

A = 0

for i in range(N):

    if i % 2 ==0:

        A += l[i]

print((A - sumB))
N = int(eval(input()))

l = []

sumB = 0

for i in range(N):

    a, b = list(map(int, input().split()))

    l.append(a + b)

    sumB += b

l.sort(reverse=True)

A = 0

for i in range(0, N, 2):

        A += l[i]

print((A - sumB))
N = int(eval(input()))
l = []
sumB = 0
for i in range(N):
    tmp = list(map(int, input().split()))
    l.append(tmp[0] + tmp[1])
    sumB += tmp[1]
l.sort(reverse=True)
A = 0
for i in range(N):
    if i % 2 == 0:
        A += l[i]
print((A - sumB))

N = int(eval(input()))
l = []
sumB = 0
for i in range(N):
    a, b = list(map(int, input().split()))
    l.append(a + b)
    sumB += b
l.sort(reverse=True)
A = 0
for i in range(0, N, 2):
    A += l[i]
print((A - sumB))

-    tmp = list(map(int, input().split())) -    l.append(tmp[0] + tmp[1]) -    sumB += tmp[1] +    a, b = list(map(int, input().split())) +    l.append(a + b) +    sumB += b -for i in range(N): -    if i % 2 == 0: -        A += l[i] +for i in range(0, N, 2): +    A += l[i]