c, s = 100, 100
for _ in range(int(input())):
    a, b = map(int, input().split())
    c, s = (c, s - a) if a > b else (c - b, s) if b > a else (c, s)
print(c, s, sep='\n')

2e2771727d0b49db89a3fb7a3c6e375871e9ed81
<mask token>

<mask token>
for _ in range(int(input())):
    a, b = map(int, input().split())
    c, s = (c, s - a) if a > b else (c - b, s) if b > a else (c, s)
print(c, s, sep='\n')

c, s = 100, 100
for _ in range(int(input())):
    a, b = map(int, input().split())
    c, s = (c, s - a) if a > b else (c - b, s) if b > a else (c, s)
print(c, s, sep='\n')
