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: array_first = []
array_second = []

input_str = input()

while True:
    turns = int(input_str)

    if turns == 0:
        break

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

score_first = 0
score_second = 0

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

print(score_first, ' ', score_second)

Python: def input_n(inputfile,outputfile):
	while True:
		n = inputfile.readline()
		n = int(n)
		if n == 0:
			break
		battle(inputfile,outputfile,n)

def battle(inputfile,outputfile,n):
	apoint = 0
	bpoint = 0
	for i in range(n):
		a , b = inputfile.readline().split()
		a = int(a)
		b = int(b)
		if a > b:
			apoint += (a + b)
		elif b > a:
			bpoint += (a + b)
		else:
			apoint += a
			bpoint += b

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

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: import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect

while(True):
    score = [0, 0]
    cards = []
    n = int(input())
    if n == 0:
        break

    for i in range(n):
        cards.append(list(map(int, input().split())))

    for i in range(n):
        if cards[i][0] > cards[i][1]:
            score[0] += sum(cards[i])
        elif cards[i][0] < cards[i][1]:
            score[1] += sum(cards[i])
        else:
            score[0] += cards[i][0]
            score[1] += cards[i][1]
    print(str(score[0]) + " " + str(score[1]))

Python: while 1:
 a=b=0;n=int(input())
 if n==0:break
 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(1):
	n = int(input())
	if n == 0: break
	ap = 0
	bp = 0
	for i in range(n):
		a,b = map(int,input().split())
		if a > b: ap = a + b + ap
		elif a < b: bp = a + b + bp
		elif a == b: ap = a + ap; bp = b + bp
	print(ap,bp)

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 (b>a):
            B += (a+b)
        else:
            A+=a
            B+=b
    print("{} {}".format(A,B))
    n = int(input())

Python: # coding: utf-8
# Your code here!
def main():
    while True:
        sum_a = 0
        sum_b = 0
        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
    scores = [0, 0]
    for i in range(n):
        cards = list(map(int, input().split()))
        if cards[0] > cards[1]:
            scores[0] += cards[0] + cards[1]
        elif cards[0] < cards[1]:
            scores[1] += cards[0] + cards[1]
        else:
            scores[0] += cards[0]
            scores[1] += cards[1]
    print(' '.join([str(score) for score in scores]))

Python: import sys
for e in sys.stdin:
 a=b=0;n=int(e)
 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: def main():
    while True:
        n = int(input())
        if n:
            aa,ba = 0,0
            a,b = [None]*n,[None]*n
            for i in range(n):
                a[i],b[i] = map(int, input().split())
                if a[i] > b[i]:
                    aa += (a[i]+b[i])
                elif a[i] < b[i]:
                    ba += (a[i]+b[i])
                else:
                    aa += a[i]
                    ba += b[i]
            print(aa,ba)
        else:
            break

if __name__ == '__main__':
    main()

Python: while True:
  A, B = 0, 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 %d'%(A,B))

Python: def evaluate_score(data):
    a_score = 0
    b_score = 0
    for a, b in data:
        if a > b:
            a_score += (a + b)
        elif b > a:
            b_score += (a + b)
        else:
            a_score += a
            b_score += b
    return a_score, b_score


if __name__ == '__main__':
    # ??????????????\???
    while True:
        data_num = int(input())
        if data_num == 0:
            break
        data = []
        for i in range(data_num):
            data.append([int(x) for x in input().split(' ')])

        # ???????????????
        a_scores, b_scores = evaluate_score(data)

        # ???????????¨???
        print('{0} {1}'.format(a_scores, b_scores))

Python: while True:
    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: 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
    else:
      a_score += a
      b_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)