#include <cstdio>
int main() {
	int n,a,b,ap,bp;
	while(scanf("%d",&n),n) {
		ap=bp=0;
		for(int i=0;i<n;i++) {
			scanf("%d %d",&a,&b);
			if(a>b)ap+=a+b;
			else if(a<b)bp+=a+b;
			else ap+=a,bp+=b;
		}
		printf("%d %d\n",ap,bp);
	}
}