import std.stdio, std.string, std.conv, std.array;

void main()
{
	while(true) {
		string[] input = split(chomp(readln));
		int N = to!int(input[0]);
		if(N == 0) break;

		int l,r;

		for(int n=0; n<N; n++) {
			input = split(chomp(readln));
			int a = to!int(input[0]);
			int b = to!int(input[1]);

			if(a>b) l += a + b;
			if(a<b) r += a + b;
			if(a==b) { l += a; r += b; }
		}

		writefln("%d %d", l, r);
	}
			
}