object Main extends App {
    val in = io.Source.stdin.getLines.map(_.split(" ").map(_.toInt))
    for (Array(n) <- in if n != 0) {
        var x, y = 0
        for (Array(a, b) <- in.take(n)) {
            if(a > b) x += a+b
            else if(a < b) y += a+b
            else {x += a; y+= b}
        }
        println(x + " " + y)
    }
}