N = int(eval(input()))

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

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



ans = 0

for i in range(N):

    if i % 2 == 0:

        ans += e[i][0]

    else:

        ans -= e[i][1]

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

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

ab.sort(key=lambda x: sum(x), reverse=True)

s = sum(a for a, _ in ab)

s -= sum(sum(dish) for dish in ab[1::2])

print(s)

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

n = int(eval(input()))
ab = [tuple(map(int, input().split())) for _ in range(n)]
ab.sort(key=lambda x: sum(x), reverse=True)
s = sum(a for a, _ in ab)
s -= sum(sum(dish) for dish in ab[1::2])
print(s)

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