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<stdio.h>
void judge(int n, int a[], int b[], int *result1, int *result2) {
	while (--n >= 0) {
		if (a[n] > b[n]) {
			*result1 += a[n] + b[n];
		}
		else if (a[n] < b[n]) {
			*result2 += a[n] + b[n];
		}
		else if (a[n] == b[n]) {
			*result1 += a[n];
			* result2 += b[n];
		}
	}
}
int main() {
	int a[10];
	int b[10];
	int n, t = 0;
int i;
	int result1 = 0, result2 = 0;
	int result[10][2];
	do {
		scanf("%d", &n);
		for (i = 0; i < n; i++) {
			scanf("%d %d", &a[i], &b[i]);
		}
		judge(n, a, b, &result1, &result2);
		result[t][0] = result1;
		result[t][1] = result2;
		result1 = 0;
		result2 = 0;
		t++;
	} while (n != 0);

	for (i = 0; i < t-1;i++) {
		printf("%d %d\n", result[i][0], result[i][1]);
	}

	return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
	int n,a,b,pa = 0,pb = 0;

	cin >> n;
	for(; n > 0; n--){
		cin >> a;
		cin >> 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 <stdio.h>

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

C++: #include <iostream>
using namespace std;
int main(void)
{
	int a,b,c,d;
	int e=0;
	int f=0;
	cin>>a;
	for (b=0;b<a;b++)
	{
		cin>>c>>d;
		if (c>d)
		{
			e=e+c+d;
		}
		else if (c<d)
		{
			f=f+d+c;
		}
		else if (c==d)
		{
			e=e+c+d;
			f=f+d+c;
		}
	}
	cout<<e<<" "<<f<<endl;
	return 0;
}

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

int main(){
  int n;
  int Acard,Bcard;
  int Atotal,Btotal;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>Acard>>Bcard;
    if(Acard>Bcard){
      Atotal+=Acard+Bcard;
    }else if(Bcard>Acard){
      Btotal+=Acard+Bcard;
    }else{
      Atotal+=Acard;
      Btotal+=Bcard;
    }
  }

  cout<<Atotal<<' '<<Btotal<<'\n';
  return 0;
}

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;
    while(true) {
        cin >> n;
        if (n==0) return 0;
        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 <stdio.h>
int n,i,j,k;
int A[1],B[1];
int main(){
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf(" %d %d",&j,&k);
    if(j>k){
      A[0]+=(j+k);
    } else if(j<k){
      B[0]+=(j+k);
    } else if(j==k){
      A[0]+=j;
      B[0]+=k;
    }
  }
  printf("%d %d\n",A[0],B[0]);
  return 0;
}

C++: #include <iostream>
#include <sstream>
#include <vector>

using namespace std;

int main(void) {
	int n;
	vector<string> v;

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

		int a = 0, b = 0, t_a = 0, t_b = 0;
		for (int i = 0; i < n; i++) {
			cin >> a >> b;
			if (a > b) {
				t_a += a + b;
			}
			else if(a < b){
				t_b += a + b;
			}
			else {
				t_a += a;
				t_b += b;
			}
		}
		
		stringstream ss;
		ss << t_a << " " << t_b;
		v.push_back(ss.str());
	}

	for (int j = 0; j < v.size(); j++) {
		cout << v[j] << endl;
	}

	return 0;
}

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

int main() {
	int num;
	int score_a[5];
	int score_b[5];
	int cnt = 0;
	bool flg = true;
	
	cin >> num;
	while (flg) {
		for (int i = 0; i < num; i++) {
			int a;
			int b;

			cin >> a >> b;
			if (a > b) {
				score_a[cnt] += a + b;
			}else if (b > a) {
				score_b[cnt] += a + b;
			}else {
				score_a[cnt] += a;
				score_b[cnt] += b;
			}
		}
		cnt++;
		cin >> num;
		if ((cnt == 5) || (num == 0)) {
			flg = false;
		}
	}

	return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>

using namespace std;

int main()
{
	while(1)
	{
		int aSum(0),bSum(0);
		int n;

		cin >> n;
		
		if(n == 0)
			break;

		for(int i = 0;i < n;i++)
		{
			int a,b;
			cin >> a >> b;
		
			if(a > b){
				aSum += a + b;
			}else if(a < b){
				bSum += a + b;
			}else{
				aSum += a;
				bSum += b;
			}
		}
		cout << aSum << " " << bSum << " " << endl;

	}
	printf("\b");
	return 0;
}

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

int main(){
	int n=0,a=0,b=0;
	while(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 <iostream>
using namespace std;

int main() {
	int q[10001], w[10001];
	
	int x = 1;
	while (1) {
		int n;
		int a = 0;
		int b = 0;
		cin >> n;
		if (n == 0) {
			break;
		}

		for (int i = 1; i <= n; ++i) {
			int c, d;
			cin >> c >> d;
			if (c == d) {
				a = a + c;
				b = b + d;
			}
			else if (c > d) {
				a = a + c + d;
			}
			else {
				b = b + c + d;
			}
		}
		q[x] = a;
		w[x] = b;
		x = x + 1;
	}
	for (int j = 1; j <= x; ++j) {
		cout << q[j] << endl;
		cout << w[j] << endl;
	}
}