fin_a = []

fin_b = []

while True:

    x = int(eval(input()))

    if x == 0:

        break

    a = 0

    b = 0

    for i in range(x):

        l = list(map(int, input().split()))

        if l[0] > l[1]:

            a += l[0] + l[1]

        elif l[0] < l[1]:

            b += l[0] + l[1]

        else:

            a += l[0]

            b += l[1]

    fin_a.append(a)

    fin_b.append(b)

    

for x, y in zip(fin_a, fin_b):

    print((x, y))
while True:

    n = int(eval(input()))

    score = [0, 0]

    if n == 0:

        break

    for _ in range(n):

        A, B = list(map(int, input().split()))

        if A == B:

            score[0], score[1] = score[0]+A, score[1]+B

        else:

            score[A<B] += A+B

    print((*score))
fin_a = []
fin_b = []
while True:
    x = int(eval(input()))
    if x == 0:
        break
    a = 0
    b = 0
    for i in range(x):
        l = list(map(int, input().split()))
        if l[0] > l[1]:
            a += l[0] + l[1]
        elif l[0] < l[1]:
            b += l[0] + l[1]
        else:
            a += l[0]
            b += l[1]
    fin_a.append(a)
    fin_b.append(b)
for x, y in zip(fin_a, fin_b):
    print((x, y))

while True:
    n = int(eval(input()))
    score = [0, 0]
    if n == 0:
        break
    for _ in range(n):
        A, B = list(map(int, input().split()))
        if A == B:
            score[0], score[1] = score[0] + A, score[1] + B
        else:
            score[A < B] += A + B
    print((*score))

-fin_a = [] -fin_b = [] -    x = int(eval(input())) -    if x == 0: +    n = int(eval(input())) +    score = [0, 0] +    if n == 0: -    a = 0 -    b = 0 -    for i in range(x): -        l = list(map(int, input().split())) -        if l[0] > l[1]: -            a += l[0] + l[1] -        elif l[0] < l[1]: -            b += l[0] + l[1] +    for _ in range(n): +        A, B = list(map(int, input().split())) +        if A == B: +            score[0], score[1] = score[0] + A, score[1] + B -            a += l[0] -            b += l[1] -    fin_a.append(a) -    fin_b.append(b) -for x, y in zip(fin_a, fin_b): -    print((x, y)) +            score[A < B] += A + B +    print((*score))