import numpy as np



N = int(eval(input()))

x = []

y = []

for i in range(N):

    a, b = [int(_) for _ in input().split()]

    x.append(a)

    y.append(b)



nx = np.array(x)

ny = np.array(y)

ns = nx + ny

arr = np.array([nx, ny, ns]).T

arr = arr[np.argsort(arr[:, 2])][::-1, :]

n = np.sum(arr[0::2, 0]) - np.sum(arr[1::2, 1])

print(n)
import numpy as np



N = int(eval(input()))

x = []

for i in range(N):

    x.extend(input().split())



a = np.array(x, dtype='int').reshape((N, 2))

s = a[:,0:1] + a[:,1:2]

a = np.hstack((a, s))

a = a[np.argsort(a[:, 2])][::-1, :]

n = np.sum(a[0::2, 0]) - np.sum(a[1::2, 1])

print(n)
import numpy as np

N = int(eval(input()))
x = []
y = []
for i in range(N):
    a, b = [int(_) for _ in input().split()]
    x.append(a)
    y.append(b)
nx = np.array(x)
ny = np.array(y)
ns = nx + ny
arr = np.array([nx, ny, ns]).T
arr = arr[np.argsort(arr[:, 2])][::-1, :]
n = np.sum(arr[0::2, 0]) - np.sum(arr[1::2, 1])
print(n)

import numpy as np

N = int(eval(input()))
x = []
for i in range(N):
    x.extend(input().split())
a = np.array(x, dtype="int").reshape((N, 2))
s = a[:, 0:1] + a[:, 1:2]
a = np.hstack((a, s))
a = a[np.argsort(a[:, 2])][::-1, :]
n = np.sum(a[0::2, 0]) - np.sum(a[1::2, 1])
print(n)

-y = [] -    a, b = [int(_) for _ in input().split()] -    x.append(a) -    y.append(b) -nx = np.array(x) -ny = np.array(y) -ns = nx + ny -arr = np.array([nx, ny, ns]).T -arr = arr[np.argsort(arr[:, 2])][::-1, :] -n = np.sum(arr[0::2, 0]) - np.sum(arr[1::2, 1]) +    x.extend(input().split()) +a = np.array(x, dtype="int").reshape((N, 2)) +s = a[:, 0:1] + a[:, 1:2] +a = np.hstack((a, s)) +a = a[np.argsort(a[:, 2])][::-1, :] +n = np.sum(a[0::2, 0]) - np.sum(a[1::2, 1])