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