#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>
using namespace std;
int result[200] = { 0 };
int main(){
		int num;
		int tmp1, tmp2, sc1 = 0, sc2= 0;
		while (cin >> num){
			sc1 = sc2 = 0;
			if (num == 0)break;
			for (int i = 0; i < num; i++){
				cin >> tmp1 >> tmp2;
				if (tmp1 == tmp2){
					sc1 += tmp1;
					sc2 += tmp2;
				}
				else if (tmp1 > tmp2)
					sc1 += tmp1 + tmp2;
				else if (tmp1 < tmp2)
					sc2 += tmp1 + tmp2;
			}
			cout << sc1 << " " << sc2 << endl;
		}
}