while True:

    n = int(eval(input()))

    if n == 0: break

    sum_a = sum_b = 0

    for i in range(n):

        a, b = list(map(int, input().split()))

        if a > b:sum_a = sum_a + a + b

        elif a < b:sum_b = sum_b + a + b

        else:

            sum_a = sum_a + a

            sum_b = sum_b + b

    print((sum_a,sum_b))



while 1:

    n = int(eval(input()))

    if n == 0:

        break

    

    sum_a = 0

    sum_b = 0

    

    for i in range(n):

        a,b = list(map(int, input().split()))

        

        if a > b:

            sum_a = sum_a + a + b

        elif a < b:

            sum_b = sum_b + a + b

        elif a == b:

            sum_a = sum_a + a

            sum_b = sum_b + b



    print(("%s %s" %(sum_a,sum_b)))



        



while True:
    n = int(eval(input()))
    if n == 0:
        break
    sum_a = sum_b = 0
    for i in range(n):
        a, b = list(map(int, input().split()))
        if a > b:
            sum_a = sum_a + a + b
        elif a < b:
            sum_b = sum_b + a + b
        else:
            sum_a = sum_a + a
            sum_b = sum_b + b
    print((sum_a, sum_b))

while 1:
    n = int(eval(input()))
    if n == 0:
        break
    sum_a = 0
    sum_b = 0
    for i in range(n):
        a, b = list(map(int, input().split()))
        if a > b:
            sum_a = sum_a + a + b
        elif a < b:
            sum_b = sum_b + a + b
        elif a == b:
            sum_a = sum_a + a
            sum_b = sum_b + b
    print(("%s %s" % (sum_a, sum_b)))

-while True: +while 1: -    sum_a = sum_b = 0 +    sum_a = 0 +    sum_b = 0 -        else: +        elif a == b: -    print((sum_a, sum_b)) +    print(("%s %s" % (sum_a, sum_b)))