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))

import sys

e=sys.stdin

while 1:

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

 if n==0:break

 for i in[0]*n:

  s,t=list(map(int,e.readline().split()))

  if s>t:a+=s+t

  elif s<t:b+=s+t

  else:a+=s;b+=t

 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))

import sys

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

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