/** * Created by Singh on 04-01-2015. */ import java.util.*; public class prog { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int black[] = new int[n]; int white[] = new int[n]; for (int i = 0; i < n; i++) { black[i]=sc.nextInt(); white[i]=sc.nextInt(); } int bg=0,wh=0; for (int i = 0; i < n; i++) { if(black[i]>white[i]) bg+=black[i]; else wh+=white[i]; } System.out.println(bg+" "+wh); } }