Go: package main

import (
	"fmt"
)

// Game is one game.
type Game struct {
	pointA, pointB int
}

func main() {
	var n int
	game := &Game{0, 0}
	fmt.Scanf("%d", &n)
	for n != 0 {
		game.initGame()
		game.execGame(n)
		game.printResult()
		fmt.Scanf("%d", &n)
	}
}

func (game *Game) execGame(n int) {
	var a, b int
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &a)
		fmt.Scanf("%d", &b)
		switch {
		case a == b:
			game.pointA += a
			game.pointB += b
		case a > b:
			game.pointA += a + b
		case b > a:
			game.pointB += a + b
		}
	}
}

func (game *Game) initGame() {
	game.pointA = 0
	game.pointB = 0
}

func (game *Game) printResult() {
	fmt.Println(game.pointA, game.pointB)
}

Python: import sys
d=0
for e in sys.stdin:
 c=list(map(int,e.split()))
 if len(c)>1:
  s,t=c;d=1
  if s>t:a+=s+t
  elif s<t:b+=s+t
  else:a+=s;b+=t
 else:
  if d:print(a,b)
  a=b=0

Python: while True:
    N = int(input())
    if N == 0:
        break

    # ??????????????????????¨???????????????°?????????
    (a, b) = (0, 0)
    
    inputs = []

    # ???????????°???????????????
    for x in range(N):
        # ??????????????????????????????
        inputs.append(list(map(int, input().split())))

    for points in inputs:
        # ?????°?????????????????????????????°???????¨?????????????
        if points[0] == points[1]:
            a = a + points[0]
            b = b + points[1]
        elif points[0] > points[1]:
            a = a + points[0] + points[1]
        else:
            b = b + points[0] + points[1]

    # ????????????????????¨???
    print(a,b)

Python: while 1:
    n=int(input())
    if n==0:
        break
    a=0
    b=0
    for i in range(n):
        x,y=map(int,input().split())
        if x > y:
            a+=(x+y)
        elif x < y:
            b+=(x+y)
        else:
            a+=x
            b+=x
    print(a,b)

Python: while True:
	N=int(input())
	if N==0:
		break
	a,b=0,0
	for i in range(N):
		info=input().split()
		A,B=int(info[0]),int(info[1])
		if A>B:
			a+=(A+B)
		elif A<B:
			b+=(A+B)
		else:
			a+=A
			b+=B
	print(str(a)+" "+str(b))

Python: while True:
    n = int(input())
    if n == 0:
        break
    score = {"A": 0, "B": 0}
    for _ in range(n):
        A, B = map(int, input().split())
        if A > B:
            score["A"] += A
        elif A < B:
            score["B"] += B
        else:
            score["A"] += A
            score["B"] += B
    print(score["A"], score["B"])

Python: while True:
    n = int(input())
    if n == 0:
        break
    a = 0
    b = 0
    for i  in range(n):
        cardnum = [int(i) for i in input().split()]
        if cardnum[0] < cardnum[1]:
            b += sum(cardnum)
        elif cardnum[0] > cardnum[1]:
            a += sum(cardnum)
        else:
            a += cardnum[0]
            b += cardnum[1]
print(a,b)

Python: N=[]
T=[]
while True:
    n = input().split()
    for e in n:
        N += [int(e)]
    if len(n) == 1 and N[-1] == 0:
        break

T += [N.pop(0)]
while T[-1] != 0:
    T += [N.pop(sum(T)*2)]

for t in T:
    if t == 0:
        break
    A = 0
    B = 0
    f = N[:t*2]
    del N[:t*2]
    for n in range(t):
        g = 2*n
        if f[g] > f[g+1]:
            A += f[g]+f[g+1]
        elif f[g] < f[g+1]:
            B += f[g]+f[g+1]
        else:
            A += f[g]
            B += f[g+1]
    print (A,B)

Python: # coding: utf-8
# Here your code !

n = int(input())

while n!=0 :
    #1??????????????¨?????????
    pointA=0
    pointB=0
    for i in range(n):
        x = list(map(int, input().split()))
        if x[0] == x[1]:
            pointA += x[0]
            pointB += x[1]
        elif x[0] > x[1]:
            pointA += x[0] + x[1]
        else:
            pointB += x[0] + x[1]
    
    print(pointA, pointB)
    n = int(input())

Python: while 1:
    A=[]
    B=[]
    n=int(input())
    
    if n==0:
        break

    else:
        for i in range(n):
            d=map(int,input().split(' '))
            D=list(d)


            if D[0]>D[1]:
                A.append(D[0])
                A.append(D[1])
                

            elif D[0]==D[1]:
                A.append(D[0])
                B.append(D[1])

            else:
                B.append(D[0])
                B.append(D[1])


    AP=sum(A)
    BP=sum(B)

    print(AP,BP)
                
                
                
            
    
    #print (A,B)

Python: while True:
    n = int(input())
    if n == 0:
        break
    A, B = 0, 0
    for _ in range(n):
        x, y = map(int, input().split())
        if x > y:
            A += x + y
        elif x < y:
            B += x + y
        else:
            A += x
            B += y
    print(A, B)

Python: n = int(input())
A = 0
B = 0
for i in range(n):
    a,b = map(int,input().split())
    if a > b:A += a + b
    elif a < b:B += a + b
    else:
        A+=a
        B+=b
print(A,B)

Python: 
def battle_A_B(A,B):
	A_points = 0
	B_points = 0
	for i in range(len(A)):
		A_idx = int(A[i])
		B_idx = int(B[i])
		if A_idx > B_idx:
			A_points += (A_idx+B_idx)
		elif A_idx < B_idx:
			B_points += (A_idx+B_idx)
		else:	
			A_points += A_idx
			B_points += B_idx	
	insert = str(A_points)+" "+str(B_points) #+"\n"
	insert_list.append(insert)


insert_list = []
while(1):
	num = input()
	num = num.rstrip("\n")
	num_list = num.split(" ")
	if len(num_list) == 1:
		if int(num_list[0]) == 0:
			break
		battle_num = int(num_list[0])
		A = []
		B = []
	else:
		A.append(num_list[0])
		B.append(num_list[1])
		if len(A) == battle_num:
			battle_A_B(A,B)	

for i in range(len(insert_list)):
	print(insert_list[i])

Python: # AOJ 0500: Card Game
# Python3 2018.6.29 bal4u

while True:
	n = int(input())
	if n == 0: break
	sa = sb = 0
	for i in range(n):
		a, b = map(int, input().split())
		if a == b:
			sa += a
			sb += b
		elif a > b: sa += a+b
		else:       sb += a+b
	print(sa, sb)

Python: import sys

while True:
	num = int(input())
	if num == 0:
		break
	point = [0,0]
	for i in range(num):
		a, b = map(int, input().split())
		if a < b:
			point[1] += a+b
		elif b < a:
			point[0] += a+b
		else:
			point[0] += a
			point[1] += b

	print(point[0], point[1])

Python: fin_a = []
fin_b = []
while True:
    x = int(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)

Python: n=int(input())
a_point=0
b_point=0
sum_list=[]
while(n!=0):
    list=[]
    for i in range(n):
        a,b=[int(i) for i in input().split()]
        if a>b:
            a_point+=(a+b)
        elif b>a:
            b_point+=(a+b)
        else:
            a_point+=a
            b_point+=b
    sum_list.append((a_point,b_point))
    a_point=0
    b_point=0
    n=int(input())

for i in range(len(sum_list)):
    print(sum_list[i][0],sum_list[i][1])

Python: while True:
    N = int(input())
    if N == 0:
        break

    # ??????????????????????¨???????????????°?????????
    (a, b) = (0, 0)
    
    inputs = []

    # ???????????°???????????????
    for x in range(N):
        # ??????????????????????????????
        inputs.append(list(map(int, input().split())))

    for points in inputs:
        # ?????°?????????????????????????????°???????¨?????????????
        if points[0] == points[1]:
            a = a + points[0]
            b = b + points[1]
        elif points[0] > points[1]:
            a = a + points[0] + points[1]
        else:
            b = b + points[0] + points[1]

    # ????????????????????¨???
    print(a,b)