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: while(True):
  loopNum = int(input())
  if loopNum == 0 :
    break
  firstScore = 0
  secondScore = 0
  for i in range(loopNum):
    scoreList = list(map(int,input().split()))
    firstNum, secondNum = scoreList
    if firstNum > secondNum:
      firstScore += firstNum + secondNum
    elif firstNum < secondNum:
      secondScore += firstNum + secondNum  
    else :
      firstScore += firstNum
      secondScore += secondNum
  print(firstScore,secondScore)

Python: while 1:
    n = int(input())
    if n == 0:
        break
    
    sum_a = 0
    sum_b = 0
    
    for i in range(n):
        a,b = 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))

Python: 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: # coding: utf-8
# Here your code !

i = int(input().rstrip())
point = []
k = 0
while i :
    point.append([0, 0])
    for j in range(i):
        l = list(map(int, input().rstrip().split()))
        if l[0] > l[1]:
            point[k][0] += l[0] + l[1]
        elif l[0] < l[1]:
            point[k][1] += l[0] + l[1]
        else:
            point[k][0] += l[0]
            point[k][1] += l[1]
    i = int(input().rstrip())
    k += 1
for i in range(k):
    print(point[i][0],point[i][1])

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

Python: while 1:
    n = input()
    if n == 0:
        break
    
    sum_a = 0
    sum_b = 0
    
    for i in range(n):
        a,b = map(int, raw_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))

Python: # coding: utf-8

while True:
	n = int(raw_input())
	if n == 0:
		break
	a = 0
	b = 0
	for i in range(n):
		cards = map(int, raw_input().split())
		if cards[0] > cards[1]:
			a += cards[0] + cards[1]
		elif cards[0] < cards[1]:
			b += cards[0] + cards[1]
		else: #cards[0] == cards[1]
			a += cards[0]
			b += cards[1]
	print("{:} {:}".format(a,b))

Python: while True:
  n = int(input())
  if n == 0:
    break
  a = 0
  b = 0
  for _ in range(n):
    s1,s2 = map(int,input().split())
    if s1 > s2:
      a += (s1 + s2)
    elif s2 > s1:
      b += (s1 + s2)
    else:
      a += s1
      b += s2
  print(a,b)

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: if __name__ == "__main__":

    while True:
        n = int(input())
        if n == 0:
            break
        else:
            g = []
            #print(n)
            sa = sb = 0
            for i in range(n):
                a, b = map(int, input().strip("\n").split(" "))
                #print(a, b)
                if a > b:
                    sa += (a + b)
                elif b > a:
                    sb += (a + b)
                else:  # a==b
                    sa += a
                    sb += b
            print(sa,sb)
pass

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

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+B
        elif A < B:
            score["B"] += A+B
        else:
            score["A"] += A
            score["B"] += B
    print(score["A"], score["B"])

Python: def _resulting(ab):
    a, b = 0, 0
    for itr in ab:
        if itr[0] > itr[1]:
            a = a + (itr[0] + itr[1])
        elif itr[0] < itr[1]:
            b = b + (itr[0] + itr[1])
        else:
            a = a + itr[0]
            b = b + itr[1]
    return a, b


if __name__ == '__main__':
    while True:
        N = int(input())
        if N != 0:
            ab = []

            for itr in range(0, N):
                ab.append(list(map(int, input().split())))

            a, b = _resulting(ab)

            print(a, b)
        else:
            break

Python: a_score, b_score = 0, 0
while(True):
  input_list = map(int, raw_input().split())
  if len(input_list) == 1 and input_list[0] == 0:
    break
  elif len(input_list) == 1 and input_list[0] != 0:
    if a_score != 0 or b_score != 0:
      print(a_score, b_score)
    a_score, b_score = 0, 0
  elif len(input_list) == 2:
    a, b = input_list
    if a > b:
      a_score += a + b
    elif b > a:
      b_score += a + b
    elif a == b:
      a_score += a
      b_score += b

Python: num_of_d = 1
while True:

    n = input()
    n = int(n)

    score_a = 0
    score_b = 0

    if n < 0 or n > 10000:
        continue
    if n == 0:
        break
    if num_of_d > 5:
        break
        
    for i in range(0, n):


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

        if a > b:
            score_a += a+b
        elif a < b:
            score_b += a+b
        else :
            score_a += a
            score_b += b

    num_of_d += 1
    print('{0} {1}' .format(score_a, score_b))

Python: while 1:
    n = input()
    if n == 0:
        break
    
    sum_a = 0
    sum_b = 0
    
    for i in range(n):
        a,b = 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))

Python: while 1:
    n = int(input())
    if n == 0:
        break
    
    sum_a = 0
    sum_b = 0
    
    for i in range(n):
        a,b = map(int, raw_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))

Python: while 1:
    n = int(input())
    if n == 0:
        break

    score_a = 0
    score_b = 0
    for _ in range(n):
        a, b = map(int, input().split())
        if a > b:
            score_a += a + b
        elif a < b:
            score_b += a + b
        else:
            score_a += a
            score_b += b

    print(score_a, score_b)