while 1:

 a=b=0;n=int(eval(input()))

 if n==0:break

 while n:

  s,t=list(map(int,input().split()))

  if s>t:a+=s+t

  elif s<t:b+=s+t

  else:a+=s;b+=t

  n-=1

 print((a,b))

import sys

for e in sys.stdin:

 a=b=0;n=int(e)

 if n:

  for i in[0]*n:

   s,t=list(map(int,input().split()))

   if s>t:a+=s+t

   elif s<t:b+=s+t

   else:a+=s;b+=t

  print((a,b))

while 1:
    a = b = 0
    n = int(eval(input()))
    if n == 0:
        break
    while n:
        s, t = list(map(int, input().split()))
        if s > t:
            a += s + t
        elif s < t:
            b += s + t
        else:
            a += s
            b += t
        n -= 1
    print((a, b))

import sys

for e in sys.stdin:
    a = b = 0
    n = int(e)
    if n:
        for i in [0] * n:
            s, t = list(map(int, input().split()))
            if s > t:
                a += s + t
            elif s < t:
                b += s + t
            else:
                a += s
                b += t
        print((a, b))

-while 1: +import sys + +for e in sys.stdin: -    n = int(eval(input())) -    if n == 0: -        break -    while n: -        s, t = list(map(int, input().split())) -        if s > t: -            a += s + t -        elif s < t: -            b += s + t -        else: -            a += s -            b += t -        n -= 1 -    print((a, b)) +    n = int(e) +    if n: +        for i in [0] * n: +            s, t = list(map(int, input().split())) +            if s > t: +                a += s + t +            elif s < t: +                b += s + t +            else: +                a += s +                b += t +        print((a, b))