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

    a_point = 0
    b_point = 0
    for _ in range(n):
        a, b = [int(x) for x in input().split()]

        if a > b:
            a_point += a + b
        elif a < b:
            b_point += a + b
        else:
            a_point += a
            b_point += b
    print(a_point, b_point)

Python: n = input()
a_cnt = 0
b_cnt = 0
for i in range(n) :
    arr = input().split(" ")
    num = [int(n) for n in arr]
    if num[0] > num[1] :
        a_cnt += sum(num)
    elif num[1] > num[0] :
        b_cnt += sum(num)
    else :
        a_cnt += num[0]
        b_cnt += num[0]
print(f"{a_cnt} {b_cnt}")

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

Python: import collections
import sys

l = collections.deque(sys.stdin.readlines())
l.pop()
s = ""
while l:
    a = 0
    b = 0
    for i in range(int(l.popleft())):
        x,y = map(int, l.popleft().split())
        if x > y:
            a = a + x + y
        elif x < y:
            b = b + x + y
        else:
            a = a+x
            b = b+y
    print(a,b)

Python: def main():
    while True:
        N = int(input())
        if N == 0:
            return
        ap, bp = 0, 0
        for i in range(N):
            a, b = map(int, input().split())
            if a > b:
                ap += a + b
            elif a < b:
                bp += a + b
            else:
                ap += a
                bp += b

        print(ap, bp)


if __name__ == '__main__':
    main()

Python: while True:
    row_num = int(input().strip())
    if row_num == 0:
        break

    user1, user2 = 0, 0
    for i in range(row_num):
        cards = [int(x) for x in input().strip().split(' ')]
        if cards[0] > cards[1]:
            user1 += sum(cards)
        elif cards[0] < cards[1]:
            user2 += sum(cards)
        else:
            user1 += cards[0]
            user2 += cards[1]
    print(user1, user2)

Python: #!/usr/bin/env python
# -*- coding: utf-8 -*-

while True:
    n = int(input())
    if n == 0:
        break
    A, B = 0, 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: n = int(input())
while n != 0:
 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("{0} {1}".format(A, B))
 n = int(input())

Python: #coding: utf-8                                                                  

def one_game():
    n = int(input())
    if n == 0:
        return False
    
    s = [list(map(int, input().split(' '))) for i in range(n)]

    win = {True: 0, False: 0}
    for a, b in s:
        if a == b:
            win[True] += a
            win[False] += a
            continue
        win[a>b] += (a + b)

    print(win[True], win[False])
    return True


while one_game() is True:
    a = 0

Python: while 1:
 a=b=0;n=int(input())
 if n:
  for i in[0]*n:
   s,t=map(int,input().split())
   if s>t:a+=s+t
   elif s<t:b+=s+t
   else:a+=s;b+=t
  print(a,b)

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

Python: n = input()
a_cnt = 0
b_cnt = 0
for i in range(n) :
    arr = input().split(" ")
    num = [int(m) for m in arr]
    if num[0] > num[1] :
        a_cnt += sum(num)
    elif num[1] > num[0] :
        b_cnt += sum(num)
    else :
        a_cnt += num[0]
        b_cnt += num[0]

print(f"{a_cnt} {b_cnt}")

Python: while True:
    n_line = input()
    if n_line == "0":
        break
    score_a, score_b = (0, 0)
    for i in range(int(n_line)):
        a, b = [int(x) for x in input().split(" ")]
        if a > b:
            score_a += a + b
        elif a < b:
            score_b += a + b
        else:
            score_a += a
            score_b += b
    print("{} {}".format(score_a, score_b))

Python: n=int(input())
while n!=0:
    a=0
    b=0
    for i in range(n):
        x,y=[int(j) for j in input().split(" ")]
        if x>y:
            a+=x+y
        elif x<y:
            b+=x+y
        else:
            a+=x
            b+=y
    print("%d %d"%(a,b))
    n=int(input())

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: def solve(N):
    A = 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)

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

Python: while True:
    x = int(input())
    if x != 0:
        resa = 0
        resb = 0
        for i in range(x):
            a, b = [int(i) for i in input().split()]
            if a > b:
                resa += a + b
            elif b > a:
                resb += a + b
            elif a == b:
                resa += a
                resb += b
        print(resa, resb)
    else:
        break

Python: while True:
    n = int(input())
    if n == 0: break
    sum_a = 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
        else:
            sum_a = sum_a + a
            sum_b = sum_b + b
    print(sum_a,sum_b)

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

    pl_card = [input().split(" ") for i in range(card_num)]
    pl_l = 0
    pl_r = 0

    for i in pl_card:
        l = int(i[0])
        r = int(i[1])
        if l > r:
            pl_l = pl_l + (l+r)
        elif l < r:
            pl_r = pl_r + (l+r)
        elif l == r:
            pl_l = pl_l + l
            pl_r = pl_r + r
    print("{0} {1}".format(pl_l,pl_r))

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