import sys



def solve():

  while(1):

    n = int(input())

    if n == 0:

      break

    score_a, score_b = 0, 0

    while(n > 0):

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

      if a > b:

        score_a += a + b

      elif b > a:

        score_b += a + b

      else:

        score_a += a

        score_b += b

      n -= 1

    print(score_a, score_b)



if __name__ == '__main__':

  solve()


def solve():

  while(1):

    n = int(input())

    if n == 0:

      break

    score_a, score_b = 0, 0

    while(n > 0):

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

      if a > b:

        score_a += a + b

      elif b > a:

        score_b += a + b

      else:

        score_a += a

        score_b += b

      n -= 1

    print(score_a, score_b)



if __name__ == '__main__':

  solve()
import sys


def solve():
    while 1:
        n = int(input())
        if n == 0:
            break
        score_a, score_b = 0, 0
        while n > 0:
            a, b = list(map(int, input().split()))
            if a > b:
                score_a += a + b
            elif b > a:
                score_b += a + b
            else:
                score_a += a
                score_b += b
            n -= 1
        print(score_a, score_b)


if __name__ == "__main__":
    solve()

def solve():
    while 1:
        n = int(input())
        if n == 0:
            break
        score_a, score_b = 0, 0
        while n > 0:
            a, b = list(map(int, input().split()))
            if a > b:
                score_a += a + b
            elif b > a:
                score_b += a + b
            else:
                score_a += a
                score_b += b
            n -= 1
        print(score_a, score_b)


if __name__ == "__main__":
    solve()

-import sys - -