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 a;
	int uma;
	int ushi;
	int b;
	int c;

	while (true){
		cin >> a;
		if (a == 0){ break; }
		else{
			for (int i; i < a; i++){
				cin >> b;
				cin >> c;
				if (b>c){
					uma = uma + b + c;
				}
				if (b == c){
					uma = uma + b;
					ushi = ushi + c;
				}
				else{
					ushi = ushi + b + c;
				}
			}
		}
		cout << uma << " " << ushi;
uma=0;
ushi=0;
	}
}

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

int main(){
    while(true){
    int n, getA = 0, getB = 0;
    cin >> n;
    if(n == 0) break;
    int A,B;
    for(int i = 0; i < n; i++){
        cin >> A >> B;
        if( A > B ) getA += A + B;
        else if( A < B ) getB += A + B;
        else{
            getA += A;
            getB += B;
        }
    }
    cout << getA << " " << getB << endl;
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int a,b,n,ansa=0,ansb=0;

	for(;;){
		cin>>n;
		if(n==0)break;
		ansa=0;
		ansb=0;
		for(int i=0;i<n;i++){
			cin>>a>>b;
			if(a>b){
				ansa=ansa+a+b;
			}
			else if(a<b){
				ansb=ansb+a+b;
			}
			else if(a==b){
				ansa=ansa+a;
				ansb=ansb+b;
			}
		}
		cout<<ansa<<" "<<ansb<<endl;
	}


	return 0;
}

C++: #include <iostream>
#include <functional>
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include <map>
#include <cmath>

using namespace std;

namespace _{struct _{_(){ // initialize
  cin.tie(0); ios::sync_with_stdio(false);
}}_;}
template <typename T, size_t size>
inline size_t len(const T (&)[size]) { return size; }
#define println(s) cout << s << '\n';
#define str to_string
#define rep(i, n) for (int i=0; i<int(n); i++)
#define all(c) (c).begin(), (c).end()


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

    int A = 0;
    int B = 0;
    rep(i, n) {
      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>

int main(){
	int n;
	while( std::cin >> n, n ){
		int sum_pt[2] = { 0, 0 };
		int pt[2];

		while( n-- ){
			std::cin >> pt[0] >> pt[1];

			if( pt[0] > pt[1] ){
				sum_pt[0] += pt[0] + pt[1];
			}else if( pt[0] < pt[1] ){
				sum_pt[1] += pt[0] + pt[1];
			}else{
				sum_pt[0] += pt[0];
				sum_pt[1] += pt[1];
			}
		}

		std::cout << sum_pt[0] << " " << sum_pt[1] << std::endl;
	}

	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <cstring>
#include <functional>

using namespace std;

#define REP(i,a,b) for((i)=(a);(i)<(int)(b);(i)++)
#define rep(i,n) REP(i,0,n)
#define foreach(itr,c) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)

int main(){
  int i,j,k,n;

  while(1){
    int ares = 0, bres = 0;
    cin >> n; if(n == 0) break;
    while(n--){
      int a, b;
      cin >> a >> b;
      if(a == b){ares += a; bres += b;}
      if(a > b) ares += (a + b);
      if(a < b) bres += (a + b);
    }
    cout << ares << " " << bres << endl;
  }

  return 0;
}

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

using namespace std;


int main(){
	int n, a, b, ta, tb;

	while (1){
		cin >> n;
		if (n == 0)break;
		ta = tb = 0;

		for (int i = 0; i < n; i++){
			cin >> a >> b;
			if (a == b){
				ta += a;
				tb += b;
			}
			else{
				a>b ? ta += a + b : tb += a + b;
			}
		}

		cout << ta << " " << tb << endl;
	}
	return 0;
}

C++: #include<cstdio>
#include<cstdlib>
#include<iostream>
#include<string>
#include<map>
#include<vector>

using namespace std;

int main(){
  
  int n,anum,bnum;
  int as, bs;
  
  as = bs = 0;
  
  while(1){
    scanf("%d",&n);
    
    if(n == 0) break;  
    
    for(int i = 0 ; i < n ; i++){
      scanf("%d%d",&anum,&bnum);
      
      if(anum == bnum){
	as += anum;
	bs += bnum;
      }
      
      else if(anum > bnum){
	as += anum;
	as += bnum; 
      }
      
      else if(anum < bnum){
	bs += anum;
	bs += bnum; 
      }  
    }
    
    printf("%d %d\n",as,bs);
  }
  return 0;
}

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

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

C++: #include <iostream>

int main(){
    
    int num,a,b,resa=0,resb=0;
    
    std::cin>>num;
    
    for(int i=0;i<num;i++){
        std::cin>>a>>b;
        if(a>b)
            resa+=a+b;
        else
        if(a<b)
            resb+=a+b;
        else
            if(a==b)
                resa+=a,resb+=b;
    }
    
    std::cout<<resa<<' '<<resb<<std::endl;
    
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
    int a,b,n;
    a=b=0;

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

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

int main(){
    int n,i,j,p1,p2;
    while(1){
        cin >> n;
        if(n == 0){
            break;
        }
        p1=0;
        p2=0;
        for(int k=0;k<n;k++){
            cin >> i >> j;
            if(i > j){
                p1 += i + j;
            }
            else if(i < j){
                p2 += i + j;
            }
            else if(i == j){
                p1 += i;
                p2 += j;
            }
        }
        cout << p1 << " " << p2 << endl;
    }
}

C++: #include<stdio.h>
int main(void)
{
	int n;
	int a,b;
	int a1,b1;
	int i;
	a1=0;
	b1=0;
	scanf("%d",&n);
	while(n!=0){
		for(i=0;i<n;i++){
			scanf("%d %d",&a,&b);
			if(a>b){
				a1+=a;
				a1+=b;
			}
			else if(a<b){
				b1+=a;
				b1+=b;
			}
			else{
				a1+=1;
				b1+=1;
			}
		}
		printf("%d %d",a1,b1);
		scanf("%d",&n);
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <map>
#include <set>
#include <stack>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()
 
#define REP(i,s,e)	for(int i=(s); i<(e); i++)
#define rep(i,n)	REP(i,0,n)
#define REPE(i,s,e)	for(int i=s; i>e; i--)
#define repe(i,n)	REPE(i,n,-1)


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<vi> vvi;
 
const int IMAX=((1<<30)-1)*2+1;
const int INF=100000000;
const double EPS=1e-10;
//int mod=1000000007
 


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