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