#include <iostream>
using namespace std;
 
int main() {
    int n;

    while(1){
    cin >> n;
    if(n == 0) break;
    int num[10000][2] = {};
    int score[2] = {};

    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < 2; ++j){
            cin >> num[i][j];
        }
        if (num[i][0] > num[i][1])
        {
            score[0] += num[i][0] + num[i][1];
        } else if (num[i][0] == num[i][1])
        {
            score[0] += num[i][0];
            score[1] += num[i][1];
        } else{
            score[1] += num[i][0] + num[i][1];
        }
    }

    cout << score[0] << " " << score[1] << endl;
    }

    return 0;
}
#include<iostream>

int main(){
	while(1){
		int n,A,B,Ap=0,Bp=0;
		std::cin>>n;
		if(n==0)
			break;
		for(int i=0;i<n;++i){
			std::cin>>A>>B;
			if(A>B)
				Ap+=A+B;
			else if(A==B){
				Ap+=A;
				Bp+=B;
			}
			else Bp+=A+B;
		}
		std::cout<<Ap<<' '<<Bp<<std::endl;
	}
	return 0;
}