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

C++: #include<iostream>

using namespace std;
#define MAX_N 10000

int N;//カードの枚数
int A[MAX_N],B[MAX_N];
int PA[MAX_N],PB[MAX_N];
int Cou = 0;//何回目の勝負か記憶しておく

int main(){
  while(true){
  scanf("%d",&N);//配られるカードの枚数
  if(N==0)
    break;
  for(int i = 0;i < N;i++){
    scanf("%d %d",&A[i],&B[i]);
    if(A[i] > B[i])
      PA[Cou] += A[i]+B[i];
    else if(A[i] < B[i])
      PB[Cou] += A[i]+B[i];
    else{
      PA[Cou] += A[i] + B[i];
      PB[Cou] += A[i] + B[i];
    }
  }
  Cou++;
  }
  for(int j = 0;j < Cou;j++){
      printf("%d %d\n",PA[j],PB[j]);
  }
  return 0;
 
}

C++: #include<stdio.h>

int main(){
	int a,b,i,n,ap,bp;
	
	for(;;){
		a=b=0;
		scanf("%d",&n);
		if(n==0) break;
		for(;n!=0;n--){
			scanf("%d%d",&ap,&bp);
			if(ap>bp) a+=ap+bp;
			else if(ap<bp) b+=ap+bp;
			else{
				a+=ap;b+=bp;
			}
		}
		printf("%d %d\n",a,b);
	}
}

C++: #include <iostream>
using namespace std;
int main(){
	int n,a,b,A,B;
	while(cin>>n,n){
		for(int i=0;i<n;i++){
			cin>>a>>b;
			if(a>b){
				A+=a;
				A+=b;
			}else if(a<b){
				B+=a;
				B+=b;
			}else{
				A+=a;
				B+=b;
			}
		}
		cout<<A<<" "<<B<<endl;
	}
}

C++: #include <stdlib.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int a[10000];
int b[10000];
int main(){
	vector<int>aa;
	vector<int>bb;
	while(1){
	int n;
	cin>>n;
	if(n==0)break;
	REP(i,n)cin>>a[i]>>b[i];
	int ans_a=0,ans_b=0;
	REP(i,n){
		if(a[i]>b[i]){
			ans_a+=(a[i]+b[i]);
		}else if(a[i]<b[i]){
			ans_b+=(a[i]+b[i]);
		}else{
			ans_a+=a[i];
			ans_b+=b[i];
		}
	}
	aa.push_back(ans_a);
	bb.push_back(ans_b);
	}
	REP(i,aa.size()){
		cout<<aa[i]<<" "<<bb[i]<<endl;
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)

int main() {
  for (int n; cin >> n, n; ) {
      int A = 0, B = 0;
      REP(i, n) {
          int a, b; cin >> a >> b;
          if (a > b) A += a + b;
          else if (a < b) B += a + b;
          else {
              A += a;
              B += b;
          }
      }
      cout << A << " " << B << endl;
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int maisuu, a[10], b[10];
	long long int a_p = 0, b_p = 0;
	int anser[2][10];
	int hasi;
	for (int i = 0; i < 5; i++){
		cin >> maisuu;
		if (maisuu == 0){
			break;
		}
		for (int i2 = 0; i2 < maisuu; i2++){
			cin >> a[i2];
			cin >> b[i2];
		}
		for (int i2 = 0; i2 < maisuu; i2++){
			if (a[i2] < b[i2]){
				b_p += a[i2] + b[i2];
			}
			else if (a[i2]>b[i2]){
				a_p += a[i2] + b[i2];
			}
			else if (a[i2] == b[i2]){
				a_p += a[i2];
				b_p += b[i2];
			}
		}
		anser[0][i] = a_p;
		anser[1][i] = b_p;
		maisuu = 0;
		a_p = 0;
		b_p = 0;
		hasi = i;
	}
	for (int i = 0; i <= hasi; i++){
		cout << anser[0][i] << " " << anser[1][i] << endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <queue>
using namespace std;

int main(void)
{
    int i;
    int num, x, y;
    int p1 = 0;
    int p2 = 0;

    for (;;) {
        scanf("%d", &num);
        if (num == 0) {
            break;
        }

        for (i = 0; i < num; i++) {
            scanf("%d %d", &x, &y);
            if (x > y) {
                p1 += (x+y);
            }
            else if (x < y) {
                p2 += (x+y);
            }
            else {
                p1 += x;
                p2 += y;
            }
        }
        printf("%d %d\n", p1, p2);
    }

    return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int n;
	while(cin >> n,n){
		int a,b,ar = 0,br = 0;
		while(n--){
			cin >> a >> b;
			ar += a>b?a+b:a==b?a:0;
			br += b>a?a+b:a==b?b:0;
		}
		cout << ar << " " << br << endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int n,a,b,c,d;
int main(){
	while(true){
		cin>>n;if(n==0)break;
		for(int i=0;i<n;i++){
			cin>>a>>b;
			if(a>b)c+=(a+b);
			if(a<b)d+=(a+b);
			if(a==b){c+=a;d+=b;}
		}
		cout<<c<<' '<<d<<endl;
	}
	return 0;
}

C++: #include <cstdio>
using namespace std;
int main()
{
	long long int a=0,b=0,n,x,y;
	scanf("%lld",&n);
	for(long long int i=0;i<n;i++){
		scanf("%lld %lld",&x,&y);
		if(x>y) a+=x+y;
		else if(x<y) b+=x+y;
		else{
			a+=x;
			b+=y;
		}
	}
	printf("%lld %lld\n",a,b);
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>

using namespace std;


int main(){
    int a,b,sa,sb,n;
    
    
    while(1){
    scanf("%d",&n);
    if(n==0) break;
    sa=0;sb=0;
    for(int i=0;i<n;i++){
        scanf("%d%d",&a,&b);
        if(a>b)
            sa+=a+b;
        else if(a<b)
            sb+=a+b;
        else{
            sa+=a;
            sb+=b;
        }
    }
    
    printf("%d %d\n",sa,sb);
    }
    return 0;
    
}

C++: #include <stdio.h>

int i;
int a, b;
int n;

int main() {
    scanf("%d", &n);
    for (i=0; i<n; i++) {
        int l, r;

        scanf("%d %d", &l, &r);
        if (l > r) {
            a += l + r;
        } else if (l < r) {
            b += l + r;
        } else {
            a += l;
            b += r;
        }
    }

    printf("%d %d\n", a, b);
}

C++: #include <cstdio>

int main() {
	int n;
	int a = 0;
	int b = 0;
	int na, nb;
	scanf("%d", &n);
	for(int i = 0; i < n; i++) {
		na = 0;nb = 0;
		scanf("%d %d", &na, &nb);
		if(na > nb) {
			a += na + nb;
		} else if(na < nb) {
			b += na + nb;
		} else {
			a += na;
			b += nb;
		}
	}
	printf("%d %d", a, b);
	return 0;
}