#include<iostream>
using namespace std;

int main(){
int n = 1;
while(1){
 cin >> n;
if (n == 0){
break;
}
int apoint = 0;int bpoint = 0;
int i = 1;
for(i = 1;i <= n;i++){
int a = 0;int b = 0;
cin >> a >> b;
if(a == b){
apoint = apoint + a;
bpoint = bpoint + b;
}
else if(a > b){
apoint = apoint + a + b;
}
else{
bpoint = bpoint + a + b;
}
} 
cout << apoint << " " << bpoint << endl;
}
    return 0;
}

#include <iostream>
using namespace std;

int main()
{
	int n, a, b, count = 0, pointX = 0, pointY = 0;
	cin >> n;
	do {
		cin >> a >> b;
		if (a > b) {
			pointX += (a + b);
		}
		else if (a < b) {
			pointY += (a + b);
		}
		else {
			pointX += a;
			pointY += b;
		}
		count++;
		if (count == n) {
			cout << pointX << " " << pointY << endl;
			pointX = pointY = count = 0;
			cin >> n;
		}
	} while (n != 0);
	return 0;
}