import scala.io.StdIn.{readInt,readLine}

object Main {
  def play(a:Int,b:Int,i:Int):(Int,Int) = {
    if(i==0) (a,b)
    else {
      val l = readLine.split(" ").map(_.toInt);val x = l(0);val y = l(1)
      if(x>y) play(a+x+y,b,i-1)
      else if(x<y) play(a,b+x+y,i-1)
      else play(a+x,b+y,i-1)
    }
  }

  def main(args:Array[String]) = {
    var n = 0
    while( { n = readInt; n } > 0 ) {
      val (a,b) = play(0,0,n)
      println(a + " " + b)
    }
  }
}