import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;

/**
 * Card Game
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0500
 *
 * @author Chida
 *
 */
public class Main {
    /** ??????:?????¬?????????A????????? */
    private static final String KEY_SCORE_A = "scoreA";
    /** ??????:?????¬?????????B????????? */
    private static final String KEY_SCORE_B = "scoreB";
    
    public static void main(String[] args) {
        
        /** ?¨??????\???????????????????????????????????£?????? */
        Scanner scan =  new Scanner(System.in);
        /** ?????¬?????????A,B?????????????????? */
        List<HashMap<String, Integer>> scoreList = new ArrayList<>();
        
        while (!scan.hasNext("0")) {
            // 1. ??????????????°?????????
            int numberOfSheets = scan.nextInt();
            
//            // ??????????????°???0?????´????????????
//            if (numberOfSheets <= 0) {
//                break;
//            }
            
            List<Integer> sheetesA = new ArrayList<Integer>();
            List<Integer> sheetesB = new ArrayList<Integer>();
            
            for (int i = 0; i < numberOfSheets; i++) {
                sheetesA.add(scan.nextInt());
                sheetesB.add(scan.nextInt());
            }
            
            // 2. A??¨B?????????????¨????
            HashMap<String, Integer> scoreMap
                = calculateScore(KEY_SCORE_A, KEY_SCORE_B, sheetesA, sheetesB);
            
            // 3. ??????????????????scoreMap?????????
            scoreList.add(scoreMap);
        }
        
        // 4. ????????????????????¨???
        for (int i = 0; i < scoreList.size(); i++) {
            StringBuilder score = new StringBuilder();
            score.append(scoreList.get(i).get(KEY_SCORE_A));
            score.append(" ");
            score.append(scoreList.get(i).get(KEY_SCORE_B));
            
            System.out.println(score.toString());
        }
    }
    
    /**
     * A??¨B?????????????¨?????????????
     *
     * @param keyA ?????¬?????????A?????????????´???????????????????
     * @param keyB ?????¬?????????B?????????????´???????????????????
     * @param sheetesA ?????¬?????????A????????????
     * @param sheetesA ?????¬?????????B????????????
     *
     * @return A??¨B?????????Map???(keyA:?????¬?????????A????????? keyB:?????¬?????????B?????????)
     */
    private static HashMap<String, Integer> calculateScore(String keyA, String keyB,
                                                     List<Integer> sheetesA,
                                                     List<Integer> sheetesB) {
        HashMap<String, Integer> scoreMap = new HashMap<String, Integer>();
        
        int mapScoreA = 0;
        int mapScoreB = 0;
        
        for (int i = 0; i < Math.min(sheetesA.size(), sheetesB.size()); i++) {
            // 1. ??\????????????
            int inputNumberA = sheetesA.get(i);
            int inputNumberB = sheetesB.get(i);
            
            // 2. A??¨B??????????????????
            if (inputNumberA > inputNumberB) {
                mapScoreA = mapScoreA + inputNumberA + inputNumberB;
            } else if (inputNumberB > inputNumberA) {
                mapScoreB = mapScoreB + inputNumberA + inputNumberB;
            } else {
                mapScoreA = mapScoreA + inputNumberA;
                mapScoreB = mapScoreB + inputNumberB;
            }
        }
        
        scoreMap.put(keyA, mapScoreA);
        scoreMap.put(keyB, mapScoreB);
        
        return scoreMap;
    }
}

Measured memory_bytes: 60908