#include <iostream>
using namespace std;

class Data{
private:
	int a_point, b_point;
public:
	Data(){ a_point=0; b_point=0;}
	void Add(int a, int b);
	void Show();
};

struct DataList{
	Data dataset;
	struct DataList* next;
};

void Data::Add(int a, int b){
	a_point += a;
	b_point += b;
}

void Data::Show(){
	cout << a_point << " " << b_point << endl;
}

int main(){
	int n, a, b;
	struct DataList *datalist, *p;

	datalist = new DataList;
	p = datalist;

	datalist->next = NULL;

	while(1){
		cin >> n;
		if(n == 0) break;

		p->next = new DataList;
		p->next->next = NULL;
		p = p->next;

		while(n > 0){
			cin >> a >> b;
			if(a > b) p->dataset.Add(a+b,0);
			else if(a < b) p->dataset.Add(0,a+b);
			else p->dataset.Add(a,b);
			n -= 1;
		}
	}

	p = datalist;

	while(p->next != NULL){
		p = p->next;
		p->dataset.Show();
	}

	return 0;
}
#include<iostream>

using namespace std;

int main() {
	int p1[10000], p2[10000], n, point1, point2, i;
	while (true) {
		point1 = 0;
		point2 = 0;
		cin >> n;
		if (n == 0) { break; }
		for (i = 0; i < n; i++) {
			cin >> p1[i] >> p2[i];
		}
		for (i = 0; i < n; i++) {
			if (p1[i] == p2[i]) {
				point1 += p1[i];
				point2 += p2[i];
			}
			else if (p1[i] > p2[i]) {
				point1 += p1[i] + p2[i];
			}
			else {
				point2 += p1[i] + p2[i];
			}
		}
		cout << point1 << ' ' << point2 << endl;
	}
	return 0;
}