#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main(){	
	int n;
	while (cin >> n, n){
		int x[2] = {};
		while (n--){
			int a, b;
			cin >> a >> b;
			if (a == b) x[0] += a, x[1] += a;
			else x[a < b] += a + b;
		}
		cout << x[0] << " " << x[1] << endl;
	}

	return 0;
}