#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>
#include <string>
#include <stack>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <vector>

using namespace std;





int main()
{
	int n;
	int a[10000], b[10000];
	while (cin >> n,n) {
		int A = 0; 
		int B = 0;
		for (int i = 0; i < n; i++) {
			cin >> a[i] >> b[i];
		}
		for (int i = 0; i < n; i++) {
			if (a[i] > b[i]) A += a[i] + b[i];
			else if (a[i] < b[i]) B += a[i] + b[i];
			else {
				A += a[i];
				B += b[i];
			}
		}
		cout << A << " " << B << endl;
	}
}