N = int(eval(input()))

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

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



a = b = 0

for i,(x,y) in enumerate(reversed(src)):

    if i%2:

        b += y

    else:

        a += x

print((a-b))
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()))
src = [tuple(map(int, input().split())) for i in range(N)]
src.sort(key=lambda x: sum(x))
a = b = 0
for i, (x, y) in enumerate(reversed(src)):
    if i % 2:
        b += y
    else:
        a += x
print((a - b))

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)

-src = [tuple(map(int, input().split())) for i in range(N)] -src.sort(key=lambda x: sum(x)) -a = b = 0 -for i, (x, y) in enumerate(reversed(src)): +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]): -        b += y +        ans -= b -        a += x -print((a - b)) +        ans += a +print(ans)