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