#include <iostream>
#include <cstdio>
using namespace std;

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