n=int(eval(input()))

taka=[]

ao=[]

s=set()

for i in range(n):

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

    taka.append([a+b,a,i])

    ao.append([a+b,b,i])

    s.add(i)

taka.sort(reverse=True)

ao.sort(reverse=True)

takapt=0

takaind=0

aopt=0

aoind=0

while len(s)>0:

    while taka[takaind][2] not in s:

        takaind+=1

    s.remove(taka[takaind][2])

    takapt+=taka[takaind][1]

    if len(s)==0:

        break

    while ao[aoind][2] not in s:

        aoind+=1

    s.remove(ao[aoind][2])

    aopt+=ao[aoind][1]

print((takapt-aopt))

n=int(eval(input()))

l=[]

for i in range(n):

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

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

l.sort(reverse=True)

t=0

a=0

for i in range(n):

    if i%2==0:

        t+=l[i][1]

    else:

        a+=l[i][2]

print((t-a))



n = int(eval(input()))
taka = []
ao = []
s = set()
for i in range(n):
    a, b = list(map(int, input().split()))
    taka.append([a + b, a, i])
    ao.append([a + b, b, i])
    s.add(i)
taka.sort(reverse=True)
ao.sort(reverse=True)
takapt = 0
takaind = 0
aopt = 0
aoind = 0
while len(s) > 0:
    while taka[takaind][2] not in s:
        takaind += 1
    s.remove(taka[takaind][2])
    takapt += taka[takaind][1]
    if len(s) == 0:
        break
    while ao[aoind][2] not in s:
        aoind += 1
    s.remove(ao[aoind][2])
    aopt += ao[aoind][1]
print((takapt - aopt))

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

-taka = [] -ao = [] -s = set() +l = [] -    taka.append([a + b, a, i]) -    ao.append([a + b, b, i]) -    s.add(i) -taka.sort(reverse=True) -ao.sort(reverse=True) -takapt = 0 -takaind = 0 -aopt = 0 -aoind = 0 -while len(s) > 0: -    while taka[takaind][2] not in s: -        takaind += 1 -    s.remove(taka[takaind][2]) -    takapt += taka[takaind][1] -    if len(s) == 0: -        break -    while ao[aoind][2] not in s: -        aoind += 1 -    s.remove(ao[aoind][2]) -    aopt += ao[aoind][1] -print((takapt - aopt)) +    l.append([a + b, a, b]) +l.sort(reverse=True) +t = 0 +a = 0 +for i in range(n): +    if i % 2 == 0: +        t += l[i][1] +    else: +        a += l[i][2] +print((t - a))