N = int(eval(input()))

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

AB.sort(key=lambda x:x[1]+x[0])



ans = 0

for i,(a,b) in enumerate(AB[::-1]):

    if i%2:

        ans -= b

    else:

        ans += a

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

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

AB.sort(key=lambda x:sum(x))



x = y = 0

i = 0

while AB:

    a,b = AB.pop()

    if i%2:

        y += b

    else:

        x += a

    i += 1

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

N = int(eval(input()))
AB = [tuple(map(int, input().split())) for i in range(N)]
AB.sort(key=lambda x: sum(x))
x = y = 0
i = 0
while AB:
    a, b = AB.pop()
    if i % 2:
        y += b
    else:
        x += a
    i += 1
print((x - y))

-AB.sort(key=lambda x: x[1] + x[0]) -ans = 0 -for i, (a, b) in enumerate(AB[::-1]): +AB.sort(key=lambda x: sum(x)) +x = y = 0 +i = 0 +while AB: +    a, b = AB.pop() -        ans -= b +        y += b -        ans += a -print(ans) +        x += a +    i += 1 +print((x - y))