#include<iostream>
using namespace std;

int main(){
  int n;
  int a,b,A,B;

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