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++: //#define _GRIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-9)
#define MOD (int)(1e9+7)
#define INF numeric_limits<int>::infinity()
#pragma endregion


int main()
{
    int n;
    cin >> n;
    vi v(2,0);
    rep(i,n) {
        int a, b;
        cin >> a >> b;
        if (a>b) {
            v[0] += a + b;
        } else if (a<b) {
            v[1] += a + b;
        } else {
            v[0] += a;
            v[1] += b;
        }
    }
    printf("%d %d\n", v[0], v[1]);
    return 0;
}

C++: #include<iostream>
using namespace std;
int i, n, pA, pB, tA = 0, tB = 0;
int main(){
while(cin >> n) {
if(n == 0) { break; }
for (i=1; i<=n; i++) {
cin >> pA >> pB;
if (pA > pB) {
tA += pA + pB;
} else {
if (pA < pB) {
tB += pA + pB;
} else {
tA += pA;
tB += pB;
}
}
}
cout << tA << "" << tB << endl;
tA = 0; tB = 0;
}
return 0;
}

C++: aaaa

C++: #include<iostream>
using namespace std;
int main(){
  int n,a[10000],b[10000],ap,bp;
  while(1){
    cin>>n;
    if(n==0)break;
    ap=0,bp=0;
    for(int i=0;i<n;i++){
      cin>>a[i]>>b[i];
    }
    for(int i=0;i<n;i++){
      if(a[i]>b[i]){
	ap+=a[i]+b[i];
      }else if(a[i]<b[i]){
	bp+=a[i]+b[i];
      }else if(a[i]==b[i]){
	ap+=a[i];
	bp+=b[i];
      }
    }
    cout<<ap<<" "<<bp<<endl;
  }
  return 0;
}

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

int main() {
	int a,b,n;
	while(1){
		cin>>n;
		if(n==0)break;
		int Pa=0,Pb=0;
		for(int i=0;i<n;i++){
			cin >>a>>b;
			if(a>b)Pa+=a+b;
			else if(a<b)Pb+=a+b;
			else{Pa+=a;Pb+=b;}
		}
		
		cout<<Pa<<" "<<Pb<<endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#define fo(i,a) for(i = 0;i < a;i++)
using namespace std;
int main(void)
{
	int n,a=0,b=0,x,y,i;
	
	cin >> n ;
	while(n != 0){
		fo(i,n){
			cin >> x >> y ;
			if(x > y) a += x + y ;
			else if(x < y) b += x + y ;
			else{
				a += x ;
				b += y ;
			}
		}
		
		cout << a << " " << b << endl ;
		a = 0 ;
		b = 0 ;
		cin >> n ;
	}
	
	return 0;
}

C++: int main() {
	int num = 0;
	int a[10000] = { 0 };
	int	b[10000] = { 0 };
	cin >> num;
	while (num != 0) {
		int ap = 0;
		int	bp = 0;
		for (int i = 0; i < num; i++) {
			cin >> a[i] >> b[i];
			if (a[i] > b[i]) ap += a[i] + b[i];
			else if (a[i] < b[i]) bp += a[i] + b[i];
			else {
				ap += a[i];
				bp += b[i];
			}
		}
		cout << ap << " " << bp << endl;
		cin >> num;
	}
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    while(cin >> n, n)
    {
        int A = 0, B = 0;
        for(int i = 0; i < n; i++)
        {
            int a, b;
            cin >> a >> b;
            if(a == b)
            {
                A += a;
                B += b;
            }
            else if(a > b)
            {
                A += a + b;
            }
            else
            {
                B += a + b;
            }
        }
        cout << A << " " << B << endl;
    }
    return 0;
}

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

int main(){
	int n=0,a=0,b=0;
	cin>>n;
	while(n-->0){
		int x=0,y=0;
		cin>>x>>y;
		if(x>y){
			a+=x+y;
		}
		if(x==y){
			a+=x;
			b+=y;
		}
		if(x<y){
			b+=x+y;
		}
	}
	cout<<a<<' '<<b<<endl;
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)+1):((m)-(n)+1)),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long INTEGER;
typedef double FLOAT;

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

int main()
{
entry:;

  int n; cin >> n;

  if (!n) return 0;

  int A = 0;
  int B = 0;
  rep (i, n) {
    int a, b; cin >> a >> b;
    if (a > b) {
      A += a + b;
    } else if (a == b) {
      A += a;
      B += b;
    } else {
      B += a + b;
    }
  }
  cout << A << ' ' << B << endl;

  goto entry;

  return 0;
}

C++: #include<iostream>
#include<vector>
#include<queue>
#include<vector>
#include<map>
#include<algorithm>

using namespace std;

int main() {
	while (true) {
		int n = 0;
		cin >> n;
		if (n == 0) {
			break;
		}

		int a = 0;
		int b = 0;
		for (int i = 0; i < n; ++i) {
			int s, t;
			cin >> s >> t;
			if (s > t) {
				a += s + t;
			} else if (s < t) {
				b += s + t;
			} else {
				a += s;
				b += t;
			}
		}

		cout << a << " " << b << endl;

	}
	return 0;
}