function main() {
  var
  i, n, a, b, line, lines;
  for(i = 0; n = parseFloat(input[i++]); ) {
    a = b = 0;
    for(j = 0; j < n; j++) {
      line = input[i++].split(' ').map(parseFloat);
      x = line[0];
      y = line[1];
      if(x > y) {
        a += x + y;
      } else if(x < y) {
        b += x + y;
      } else {
        a += x;
        b += y;
      }
    }
    console.log("%d %d", a, b);
  }
}

var
input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});