#include <iostream>
using namespace std;
 
int main()
{
    int n,a,b,x,y;
    while(cin >> n, n)
    {
        x=0, y=0;
        while(n--)
        {
            cin >> a >> b;
            if(a< b) {y+=a+b;}
            if(a> b) {x+=a+b;}
            if(a==b) {x+=a;y+=b;}
        }
        cout << x << " " << y << endl;
    }
}