
import std.stdio, std.array;

void main() {
  for(int t; readf("%d\n", &t), t != 0;) {
    int x_point = 0, y_point = 0;
    int[] x, y;
    foreach(i; 0..t) {
      int a, b;
      readf("%d %d\n", &a, &b);
      x ~= a;
      y ~= b;
    }
    while(x.length != 0 && y.length != 0) {
      int n = x.front;
      int m = y.front;
      x.popFront; y.popFront;
      if (n == m) {x_point += n; y_point += m;}
      else if (n > m) {
        x_point += (n + m);
      }
      else {
        y_point += (n + m);
      }
    }
    writeln(x_point, " ", y_point);
  }
}