object Main extends App {
    val in = io.Source.stdin.getLines.map(_.split(" ").map(_.toInt)).toList.tail
    val ans = in.foldLeft((0, 0))((p, q) => {
        if(q(0) > q(1)) (p._1+q(0)+q(1), p._2)
        else if(q(0) < q(1)) (p._1, p._2+q(0)+q(1))
        else (p._1+q(0), p._2+q(1))
    })
    println(ans._1 + " " + ans._2)
}