n=int(eval(input()))

x=[]

for _ in range(n):

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

    x.append([a+b,a,b])

x.sort(reverse=True)

ans=0

for i in range(n):

    if i%2==0: ans+=x[i][1]

    else: ans-=x[i][2]

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

x=[]

ans=0

for _ in range(n):

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

    x.append(a+b)

    ans-=b

x.sort(reverse=True)

ans+=sum(x[i] for i in range(n) if i%2==0)

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

n = int(eval(input()))
x = []
ans = 0
for _ in range(n):
    a, b = list(map(int, input().split()))
    x.append(a + b)
    ans -= b
x.sort(reverse=True)
ans += sum(x[i] for i in range(n) if i % 2 == 0)
print(ans)

+ans = 0 -    x.append([a + b, a, b]) +    x.append(a + b) +    ans -= b -ans = 0 -for i in range(n): -    if i % 2 == 0: -        ans += x[i][1] -    else: -        ans -= x[i][2] +ans += sum(x[i] for i in range(n) if i % 2 == 0)