n = int(eval(input()))

a, b, c = [], [], []

for i in range(n):

    av, bv = list(map(int, input().split()))

    a.append(av)

    b.append(bv)

    c.append((i, av + bv))



c = sorted(c, key=lambda x: x[1], reverse=True)

takahaship, aokip = 0, 0

i = 0

for _ in c:

    if i % 2 == 0:

        takahaship += a[c[i][0]]

    else:

        aokip += b[c[i][0]]

    i += 1

print((takahaship - aokip))

n = int(eval(input()))

sb = 0

a, b, d = [], [], []

for i in range(n):

    av, bv = list(map(int, input().split()))

    a.append(av)

    b.append(bv)

    d.append([i, av + bv])

d = sorted(d, key=lambda x: x[1], reverse=True)

tk, ao = 0, 0

for i in range(n):

    if i % 2 == 0:

        tk += a[d[i][0]]

    else:

        ao += b[d[i][0]]

print((tk - ao))
n = int(eval(input()))
a, b, c = [], [], []
for i in range(n):
    av, bv = list(map(int, input().split()))
    a.append(av)
    b.append(bv)
    c.append((i, av + bv))
c = sorted(c, key=lambda x: x[1], reverse=True)
takahaship, aokip = 0, 0
i = 0
for _ in c:
    if i % 2 == 0:
        takahaship += a[c[i][0]]
    else:
        aokip += b[c[i][0]]
    i += 1
print((takahaship - aokip))

n = int(eval(input()))
sb = 0
a, b, d = [], [], []
for i in range(n):
    av, bv = list(map(int, input().split()))
    a.append(av)
    b.append(bv)
    d.append([i, av + bv])
d = sorted(d, key=lambda x: x[1], reverse=True)
tk, ao = 0, 0
for i in range(n):
    if i % 2 == 0:
        tk += a[d[i][0]]
    else:
        ao += b[d[i][0]]
print((tk - ao))

-a, b, c = [], [], [] +sb = 0 +a, b, d = [], [], [] -    c.append((i, av + bv)) -c = sorted(c, key=lambda x: x[1], reverse=True) -takahaship, aokip = 0, 0 -i = 0 -for _ in c: +    d.append([i, av + bv]) +d = sorted(d, key=lambda x: x[1], reverse=True) +tk, ao = 0, 0 +for i in range(n): -        takahaship += a[c[i][0]] +        tk += a[d[i][0]] -        aokip += b[c[i][0]] -    i += 1 -print((takahaship - aokip)) +        ao += b[d[i][0]] +print((tk - ao))