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:
    n = int(input())
    if n == 0:break
    sumA = sumB = 0
    for i in range(n):
        c = list(map(int,input().split()))
        if c[0]==c[1]:
            sumA = sumA+c[0]
            sumB = sumB+c[1]
        else:
            sumA = sumA + (c[0]+c[1] if c[0]>c[1] else 0)
            sumB = sumB + (c[0]+c[1] if c[1]>c[0] else 0)
    print(sumA, " " , sumB)

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

Python: x = int(input())
score_A = 0
score_B = 0
ans = []
while x:
    for i in range(x):
        y = [int(i) for  i in input().split()]
        if y[0] > y[1]:
            score_A += sum(y)
        elif y[0] < y[1]:
            score_B += sum(y)
        else:
            score_A += y[0]
            score_B += y[1]
    ans.append([score_A,score_B])
    score_A = 0 ; score_B = 0
    x = int(input())
for i in ans:
    print(*i)

Python: def main():
    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))
                
if __name__ == "__main__":
    main()

Python: # coding: utf-8

line = input()
while line != "0":
    gameCount = int(line)
    pointOfA = 0
    pointOfB = 0
    for count in range(gameCount):
        cardOfA, cardOfB = list(map(int, input().split(" ")))
        if cardOfA > cardOfB:
            pointOfA += cardOfA + cardOfB
        elif cardOfB > cardOfA:
            pointOfB += cardOfA + cardOfB
        else:
            pointOfA += cardOfA
            pointOfB += cardOfB
    print("{0} {1}".format(pointOfA, pointOfB))
    line = input()

Python: while True:
  n = int(input().rstrip())
  if n == 0:
    break
  A = 0
  B = 0
  while n > 0:
    line = input().rstrip()
    a,b = map(int,line.split())
    if a == b:
      A += a
      B += b
    elif a > b:
      A += (a+b)
    else:
      B += (a+b)
    n -= 1
  print(A,B)

Python: n = 1
while n!=0:
  A = 0
  B = 0
  n = int(input())
  if n == 0:
    break
  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('%d%s%d'%(A,' ',B))

Python: #----------------
# coding: utf-8
# Created:     20/08/2014
# Python 3+
#-----------------
import sys
#ff = open("test.txt", "r")
ff = sys.stdin

while (True) :

    n = int(ff.readline())
    if n == 0 : break

    p1 = 0
    p2 = 0

    for x in range(0, n):
        arr = list( map(int, ff.readline().split()) )
        sum = arr[0] + arr[1]

        if arr[0] == arr[1] :
            p1 += arr[0]
            p2 += arr[1]
        elif arr[0] > arr[1] :
            p1 += sum
        else :
            p2 += sum

    print("{0} {1}".format(p1, p2))

pass

Python: def main():
    sum_a = 0
    sum_b = 0
    while True:
        n = input()
        if n == '0':
            return 
        for i in range(int(n)):
            a,b = list(map(int, input().split()))
            if a > b:
                sum_a += a+b
            elif a < b:
                sum_b += a+b
            else:
                sum_a += a
                sum_b += b
        print(sum_a, sum_b)

if __name__ == '__main__':
    main()

Python: while True:
    n = int(input())
    if n == 0:
        break
    a_score = 0
    b_score = 0
    for i in range(0,3):
        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: 

array_first = []
array_second = []
array_turns = []

input_str = input()

while True:
    turns = int(input_str)

    if turns == 0:
        break

    array_turns.append(turns)

    for turn in range(turns):
        input_str = input()

        first = ''
        second = ''

        flag_space = False
        for i in range(len(input_str)):
            if input_str[i] == ' ':
                flag_space = True
                continue
            if not flag_space:
                first += (input_str[i])
            else:
                second += (input_str[i])

        array_first.append(int(first))
        array_second.append(int(second))

    input_str = input()

scores_first = []
scores_second = []
passed_turns = 0

for turns in array_turns:
    score_first = 0
    score_second = 0

    for turn in range(turns):
        if array_first[turn + passed_turns] > array_second[turn + passed_turns]:
            score_first += array_first[turn + passed_turns] + array_second[turn + passed_turns]
        elif array_first[turn + passed_turns] < array_second[turn + passed_turns]:
            score_second += array_first[turn + passed_turns] + array_second[turn + passed_turns]
        else:
            score_first += array_first[turn + passed_turns]
            score_second += array_second[turn + passed_turns]

    scores_first.append(score_first)
    scores_second.append(score_second)
    passed_turns += turns

for idx, score in enumerate(zip(scores_first, scores_second)):
    print(score[0], score[1])

Python: 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=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)

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(sum_a,sum_b)

Python: while True:
	n = int(input())
	if n == 0:
		break
	game = [[int(s) for s in input().split()] for i in range(n)]
	a,b = 0,0
	for g in game:
		if g[0] > g[1]:
			a += sum(g)
		elif g[0] < g[1]:
			b += sum(g)
		else:
			a += g[0]
			b += g[1]
	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: def foo(infile, outfile, n):
    ax = 0
    bx = 0
    for i in range(n):
        a, b = infile.readline().split()
        a = int(a)
        b = int(b)
        if a > b:
            ax += (a + b)
        elif a < b:
            bx += (a + b)
        elif a == b:
            ax += a
            bx += b
        else:
            assert False
    print >> outfile, ax, bx


def run(infile, outfile):
    while True:
        n = int(infile.readline())
        if n == 0:
            break
        foo(infile, outfile, n)


if __name__ == "__main__":
    import sys
    run(sys.stdin, sys.stdout)