
#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;
}
#include <iostream>

int main(){
	std::ios::sync_with_stdio(false);
    while(true){
    int n, a_score = 0, b_score = 0;
    std::cin >> n;
    
    if(n == 0)
        break;

    for(int i = 0; i < n; ++i){
        int a, b;
        std::cin >> a >> b;
        if(a > b)
            a_score += a + b;
        else if(a < b)
            b_score += a + b;
        else
            a_score += a, b_score += b;
    }

    std::cout << a_score << " " << b_score << std::endl;
    }
    return 0;
}