import collections

import sys



l = collections.deque(sys.stdin.readlines())

l.pop()

s = ""

while l:

    a = 0

    b = 0

    for i in range(int(l.popleft())):

        x,y = map(int, l.popleft().split())

        if x > y:

            a = a + x + y

        elif x < y:

            b = b + x + y

        else:

            a = a+x

            b = b+y

    s += str(a) + " " + str(b) + "\n"



print(s,end="")

import collections

import sys



l = collections.deque(sys.stdin.readlines())

l.pop()

s = ""

while l:

    a = 0

    b = 0

    for i in range(int(l.popleft())):

        x,y = list(map(int, l.popleft().split()))

        if x > y:

            a = a + x + y

        elif x < y:

            b = b + x + y

        else:

            a = a+x

            b = b+y

    print((a,b))
import collections
import sys

l = collections.deque(sys.stdin.readlines())
l.pop()
s = ""
while l:
    a = 0
    b = 0
    for i in range(int(l.popleft())):
        x, y = map(int, l.popleft().split())
        if x > y:
            a = a + x + y
        elif x < y:
            b = b + x + y
        else:
            a = a + x
            b = b + y
    s += str(a) + " " + str(b) + "\n"
print(s, end="")

import collections
import sys

l = collections.deque(sys.stdin.readlines())
l.pop()
s = ""
while l:
    a = 0
    b = 0
    for i in range(int(l.popleft())):
        x, y = list(map(int, l.popleft().split()))
        if x > y:
            a = a + x + y
        elif x < y:
            b = b + x + y
        else:
            a = a + x
            b = b + y
    print((a, b))

-        x, y = map(int, l.popleft().split()) +        x, y = list(map(int, l.popleft().split())) -    s += str(a) + " " + str(b) + "\n" -print(s, end="") +    print((a, b))