from functools import lru_cache

N = int(eval(input()))



A = []

B = []

food = []



for i in range(N):

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

    A.append(a)

    B.append(b)

    food.append((a + b, i))



food.sort(reverse=True)

X = 0

Y = 0

cnt = 0



for _, i in food:

    if cnt % 2 == 0:

        X += A[i]

    else:

        Y += B[i]

    cnt += 1



print((X - Y))
N = int(eval(input()))

AB = [tuple(map(int, input().split())) for _ in range(N)]

AB.sort(key=lambda a: a[0] + a[1], reverse=True)



ans = 0

for i in range(N):

    if i % 2 == 0:

        ans += AB[i][0]

    else:

        ans -= AB[i][1]

print(ans)

from functools import lru_cache

N = int(eval(input()))
A = []
B = []
food = []
for i in range(N):
    a, b = list(map(int, input().split()))
    A.append(a)
    B.append(b)
    food.append((a + b, i))
food.sort(reverse=True)
X = 0
Y = 0
cnt = 0
for _, i in food:
    if cnt % 2 == 0:
        X += A[i]
    else:
        Y += B[i]
    cnt += 1
print((X - Y))

N = int(eval(input()))
AB = [tuple(map(int, input().split())) for _ in range(N)]
AB.sort(key=lambda a: a[0] + a[1], reverse=True)
ans = 0
for i in range(N):
    if i % 2 == 0:
        ans += AB[i][0]
    else:
        ans -= AB[i][1]
print(ans)

-from functools import lru_cache - -A = [] -B = [] -food = [] +AB = [tuple(map(int, input().split())) for _ in range(N)] +AB.sort(key=lambda a: a[0] + a[1], reverse=True) +ans = 0 -    a, b = list(map(int, input().split())) -    A.append(a) -    B.append(b) -    food.append((a + b, i)) -food.sort(reverse=True) -X = 0 -Y = 0 -cnt = 0 -for _, i in food: -    if cnt % 2 == 0: -        X += A[i] +    if i % 2 == 0: +        ans += AB[i][0] -        Y += B[i] -    cnt += 1 -print((X - Y)) +        ans -= AB[i][1] +print(ans)