Go: package main

import "fmt"

func main() {
	for {
		var a, b, n int
		fmt.Scanf("%d", &n)

		if n == 0 {
			return
		}

		for i := 0; i < n; i++ {
			var cardA, cardB int
			fmt.Scanf("%d %d", &cardA, &cardB)

			if cardA > cardB {
				a += cardA + cardB
			} else if cardB > cardA {
				b += cardA + cardB
			} else {
				a += cardA
				b += cardB
			}
		}

		fmt.Println(a, b)
	}
}

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

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

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

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

int main(){
	int n;
	while (cin >> n, n){
		int inA, inB, ansA = 0, ansB = 0;
		for (int i = 0; i < n; i++){
			cin >> inA >> inB;
			if (inA > inB) ansA += inA + inB;
			else if (inB > inA) ansB += inA + inB;
			else{
				ansA += inA;
				ansB += inB;
			}
		}
		printf("%d %d\n", ansA, ansB);
	}
}

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

int main() {
	int n,i,result[2] = {0,0};
	cin >> n;
	int num[2];
	for(i = 0;i < n;i++){
		cin >> num[0] >> num[1];
		if(num[0] > num[1])result[0]+= num[0] + num[1];
		else if(num[0] < num[1])result[1]+= num[0] + num[1];
		else if(num[0] == num[1]){
			result[0] += num[0];
			result[1] += num[1];
		}
	}
	cout << result[0] << ' ' << result[1] <<endl;
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
    int n,ap,bp,a,b;
    cin>>n;
    while(n!=0){
        ap=0;
        bp=0;
        for(int i=0;i<n;i++){
            cin>>a>>b;
            ap+=a==b?a:(a>b?a+b:0);
            bp+=a==b?b:(a<b?a+b:0);
        }
        cout<<ap<<' '<<bp<<endl;
        cin>>n;
    }
}

C++: #include<stdio.h>

int main(){

int N;int A,B,SA=0,SB=0;
while(1){
SA=0,SB=0;

scanf("%d",&N);
if(N==0)break;
for(int i=0;i<N;i++){
scanf("%d %d",&A,&B);
if(A>B)SA=SA+A+B;
else if(B>A)SB=SB+A+B;
else {SA+=A;SB+=B;}
}

printf("%d %d\n",SA,SB);
}
return 0;
}

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

int main(){
	while (1){
		int sum = 0;
		int n;
		int a_sum = 0;
		cin >> n;
		if (!n) return 0;
		for (int i = 0; i < n; i++){
			int a_num, b_num;
			cin >> a_num;
			cin >> b_num;

			if (a_num > b_num){
				a_sum += (a_num + b_num);
			}
			else if (a_num == b_num){
				a_sum += a_num;
			}
			sum += a_num + b_num;
		}

		cout << a_sum << " " << sum - a_sum << "\n";
	}
}