
import std.stdio, std.array;

void main() {
  for(int t; readf("%d\n", &t), t != 0;) {
    int a_point = 0, b_point = 0;
    foreach(i; 0..t) {
      int a, b;
      readf("%d %d\n", &a, &b);
      if (a == b) {a_point += a; b_point += b;}
      else if (a > b) {
        a_point += (a + b);
      }
      else {
        b_point += (a + b);
      }
    }
    writeln(a_point, " ", b_point);
  }
}