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++: #include <iostream>
using namespace std;

int main() {
    int AsPoint, BsPoint, AsCard, BsCard;
    int key;
    while(true){
        cin >> key;
        AsPoint = BsPoint = 0;
        if(key == 0) return 0;
        while(key != 0) {
            cin >> AsCard;
            cin >> BsCard;
            if(AsCard == BsCard) {
                AsPoint += AsCard;
                BsPoint += BsCard;
            } else {
                AsPoint += (AsCard > BsCard) ? AsCard + BsCard : 0;
                BsPoint += (BsCard > AsCard) ? AsCard + BsCard : 0;
            }
            --key;
        }
        cout << AsPoint << " " << BsPoint << endl;
    }
}

C++: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"
int main() {
	int N; cin >> N;
	int as, bs;
	for (int i = 0; i < N; ++i) {
		int a, b; cin >> a >> b;
		if (a > b) {
			as += a + b;

		}
		else if (b > a) {
			bs += a + b;
		}
		else {
			as += a;
			bs += b;
		}

	}
	cout << as <<" "<< bs << endl;
	return 0;
}

C++: #include<iostream>
#include<vector>
int main() {
	int n;
	int ag = 0, bg = 0;	
	std::cin >> n;
	std::vector<int> a(n), b(n);

	for (int i = 0; i < n; ++i) {
		std::cin >> a[i] >> b[i];
		if (a[i] > b[i]) { ag += a[i]; ag += b[i]; }
		else { bg += a[i]; bg += b[i]; }
	}
	std::cout << ag << " " << bg << std::endl;
}

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

int main()
{
    int n;
    int sum_A[5];
    int sum_B[5];
    int A, B;
    int j = 0;

    while (n != 0){
        cin >> n;
        
        for (int i = 0; i < n; i++){
            cin >> A;
            cin >> B;
            if (A > B){
                sum_A[j] += A + B;
            }
            else {
                sum_B[j] += A + B;
            }
            A = 0;
            B = 0;
        }
        for (int l = 0; l <= j; l++){
            cout << sum_A << " " << sum_B << endl;
        }
        j++;
    }
    return (0);
}

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

typedef long long ll;

int main()
{
    int n;
    while(cin >> n && n) {
        int a = 0, b = 0, c, d;
        for(int i = 0; i < n; i++) {
            cin >> c >> d;
            if(c > d) {
                a += (c + d);
            } else if(c == d) {
                a += c;
                b += d;
            } else {
                b += (c + d);
            }
        }
        cout << a << " " << b << endl;
    }
}

C++: #include <iostream>

using namespace std;

int main() {
	int n;
	while (cin >> n && n != 0) {
		int A=0, B=0, a, b;
		for (int i=0; i<n; i++) {
			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;
	}
}

C++: #include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <queue>
#include <algorithm>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const double pi=acos(-1);

ll n,A=0,B=0;

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		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;
}

C++: #include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>

using namespace std;
typedef long long Int;
#define REP(i , x) for(int i = 0 ; i < x ; ++i)
Int Ap, Bp;

int main()
{
	int n;
	int a, b;
	
	while (cin >> n, n){
		Ap = Bp = 0;
		REP(i, n){
			cin >> a >> b;
			if (a > b){
				Ap += a;
				Ap += b;
			}
			else if (a < b){
				Bp += a;
				Bp += b;
			}
			else{
				Ap += a;
				Bp += b;
			}
		}

		cout << Ap << " " << Bp << endl;
	}
	return 0;

}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
 
using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU 
 
typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 1e18;
const double PI = acos(-1);
 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    while (n != 0) {
        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;
        cin >> n;
    }
    PAU;
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int n;
	int a,b;
	int A,B;
	while(true){
		cin>>n;
			if(n==0){break;}
	for(int i=0;i<n;i++){
		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 n,a,b;
  while(cin>>n,n){
    int asum=0,bsum=0;
    for(int i=0;i<n;i++){
      cin>>a>>b;
      if(a>b)asum+=a+b;
      else if(a<b)bsum+=a+b;
      else {asum+=a; bsum+=a;}
    }
    cout<<asum<<' '<<bsum<<endl;
  }
}

C++: #include<iostream>
using namespace std;
int main(){
  int n,a,b,A,B;
  while(1){
    cin>>n;
    if(n==0)break;
    A=B=0;
    for(int i=0;i<n;i++){
      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>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<long long,int> P;
static const int INF=1<<24;

int n;
int a[10100],b[10100];

int main(){
	while(cin>>n,n){
		rep(i,n){
			cin>>a[i]>>b[i];
		}
		ll ans1=0,ans2=0;
		rep(i,n){
			if(a[i]<b[i]){
				ans2+=a[i]+b[i];
			}
			else if(a[i]==b[i]){
				ans1+=a[i];
				ans2+=b[i];
			}
			else{
				ans1+=a[i]+b[i];
			}
		}
		cout<<ans1<<" "<<ans2<<endl;
	}
	return 0;
}