#include<iostream>
using namespace std;

int main(){
	int n, a, b, p1,p2;
	while(true){
		cin>>n;
		p1=p2=0;
		if(n==0)break;
		for(int i=0;i<n;i++){
			cin>>a>>b;
			if(a>b)p1+=a+b;
			else if(a<b)p2+=a+b;
			else{
				p1+=a;
				p2+=b;
			}
		}
		cout << p1 << " " << p2 << endl;
	}
	return 0;
}