n=int(eval(input()))

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



a_b=[]

x=0

for a,b in ab:

    a_b.append(a+b)

    x-=b

a_b.sort(reverse=True)

ans=0

for i in range(0,n,2):

    ans+=a_b[i]



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

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



sum_a = 0

sum_ab = []

for a, b in ab:

    sum_a += a

    sum_ab.append(a + b)



sum_ab.sort(reverse=True)

for i in range(1, n, 2):

    sum_a -= sum_ab[i]

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

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

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