import std.stdio, std.string,std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
	string[] result;
	while (true) {
		auto n = readln.chomp.to!long;
		if (n == 0) break;
		long a, b;
		foreach (i; 0..n) {
			auto tmp = readln.split.map!(to!long).array;
			if (tmp[0] > tmp[1]) a += tmp[0] + tmp[1];
			else if (tmp[1] > tmp[0]) b += tmp[0] + tmp[1];
			else {
				a += b += tmp[0];
			}
		}
		result ~= format("%d %d", a, b);
	}
	result.each!(s => writef("%s\n", s));
}