package no230; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; import java.util.NoSuchElementException; public class Main { public static void main(String[] args) { IO io = new IO(); int n = io.nextInt(); int q = io.nextInt(); RangeSetRangeSum teamA = new RangeSetRangeSum(n); RangeSetRangeSum teamB = new RangeSetRangeSum(n); long scoreA = 0,scoreB = 0; // System.out.println("----"); // System.out.println(teamA); // System.out.println(teamB); for(int i=0;i b) { scoreA += a; }else if(a < b) { scoreB += b; } }else if(x == 1) { teamA.set(l, r, 1); teamB.set(l, r, 0); }else{ teamA.set(l, r, 0); teamB.set(l, r, 1); } // System.out.println("----"); // System.out.println(teamA); // System.out.println(teamB); } scoreA += teamA.sum(0, n-1); scoreB += teamB.sum(0, n-1); System.out.println(scoreA + " " + scoreB); } } class RangeSetRangeSum { int n; boolean[] block; int[] bdata; int[] data; int[] sum; int sqrtn; public RangeSetRangeSum(int size) { int sqrtfloor = (int) Math.sqrt(size); sqrtn = sqrtfloor + (sqrtfloor * sqrtfloor < size ? 1 : 0); n = sqrtn * sqrtn; block = new boolean[sqrtn]; bdata = new int[sqrtn]; data = new int[n]; sum = new int[sqrtn]; } public void set(int first,int last,int x) { for(int i=0;i Integer.MAX_VALUE) { throw new NumberFormatException(); } return (int) nl; } public char nextChar() { if (!hasNext()) { throw new NoSuchElementException(); } return (char) readByte(); } public double nextDouble() { return Double.parseDouble(next());} public int[] nextIntArray(int n) { int[] a = new int[n]; for(int i=0;i