n = int(eval(input()))



AB = [[0, 0, 0] for i in range(n)]

for i in range(n):

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

    AB[i][0] = a+b

    AB[i][1] = a

    AB[i][2] = b



AB.sort()

ans = 0

for i in range(n):

    _, a, b = AB.pop()

    if i%2 == 0:

        ans += a

    else:

        ans -= b

print(ans)
n =int(eval(input()))

AB = []

Sb = 0

for i in range(n):

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

    AB.append(a+b)

    Sb += b



AB.sort()

ans = 0

for i in range(n):

    if i%2 == 0:

        ans += AB.pop()

    else:

        AB.pop()

ans -= Sb

print(ans)

n = int(eval(input()))
AB = [[0, 0, 0] for i in range(n)]
for i in range(n):
    a, b = list(map(int, input().split()))
    AB[i][0] = a + b
    AB[i][1] = a
    AB[i][2] = b
AB.sort()
ans = 0
for i in range(n):
    _, a, b = AB.pop()
    if i % 2 == 0:
        ans += a
    else:
        ans -= b
print(ans)

n = int(eval(input()))
AB = []
Sb = 0
for i in range(n):
    a, b = list(map(int, input().split()))
    AB.append(a + b)
    Sb += b
AB.sort()
ans = 0
for i in range(n):
    if i % 2 == 0:
        ans += AB.pop()
    else:
        AB.pop()
ans -= Sb
print(ans)

-AB = [[0, 0, 0] for i in range(n)] +AB = [] +Sb = 0 -    AB[i][0] = a + b -    AB[i][1] = a -    AB[i][2] = b +    AB.append(a + b) +    Sb += b -    _, a, b = AB.pop() -        ans += a +        ans += AB.pop() -        ans -= b +        AB.pop() +ans -= Sb