import java.util.Arrays; import java.util.LinkedList; import java.util.Scanner; public class Main { public static class LazySegTree{ int n; long[] plus_sum, minus_sum; long[] lazy_plus, lazy_minus; int[] sign; public LazySegTree(int n_) { int n = 1; while(n < n_){ n *= 2;} this.n = n; plus_sum = new long[this.n * 2 - 1]; minus_sum = new long[this.n * 2 - 1]; lazy_plus = new long[this.n * 2 - 1]; lazy_minus = new long[this.n * 2 - 1]; sign = new int[this.n * 2 + 1]; for(int i = 0; i < this.n * 2 - 1 ; i++){ plus_sum[i] = 0; lazy_plus[i] = 0; minus_sum[i] = 0; lazy_minus[i] = 0; sign[i] = 0; } } private void evaluate_node(int k, int a, int b){ if(sign[k] == 0){ return; } if(sign[k] == 1){ plus_sum[k] += lazy_plus[k] * (b - a); minus_sum[k] = 0; }else if(sign[k] == -1){ plus_sum[k] = 0; minus_sum[k] += lazy_minus[k] * (b - a); } if(k < n - 1){ sign[k * 2 + 1] = sign[k]; sign[k * 2 + 2] = sign[k]; if(sign[k] == 1){ lazy_plus[k * 2 + 1] = lazy_plus[k]; lazy_plus[k * 2 + 2] = lazy_plus[k]; lazy_minus[k * 2 + 1] = 0; lazy_minus[k * 2 + 2] = 0; }else if(sign[k] == -1){ lazy_plus[k * 2 + 1] = 0; lazy_plus[k * 2 + 2] = 0; lazy_minus[k * 2 + 1] = lazy_minus[k]; lazy_minus[k * 2 + 2] = lazy_minus[k]; } } sign[k] = 0; lazy_plus[k] = lazy_minus[k] = 0; } public void update_node(int k){ plus_sum[k] = plus_sum[2 * k + 1] + plus_sum[2 * k + 2]; minus_sum[k] = minus_sum[2 * k + 1] + minus_sum[2 * k + 2]; } public void update(long v, int a, int b, int k, int l, int r){ evaluate_node(k, l, r); final int signum = Long.signum(v); if(r <= a || b <= l){ return; }else if(a <= l && r <= b){ sign[k] = signum; if(signum == 1){ lazy_plus[k] = v; lazy_minus[k] = 0; }else if(signum == -1){ lazy_plus[k] = 0; lazy_minus[k] = v; } evaluate_node(k, l, r); }else{ update(v, a, b, 2 * k + 1, l, (l + r) / 2); update(v, a, b, 2 * k + 2, (l + r) / 2, r); update_node(k); } } public long get_plus(int a, int b, int k, int l, int r){ evaluate_node(k, l, r); if(r <= a || b <= l){ return 0; }else if(a <= l && r <= b){ return plus_sum[k]; }else { long v1 = get_plus(a, b, k * 2 + 1, l, (l + r) / 2); long v2 = get_plus(a, b, k * 2 + 2, (l + r) / 2, r); update_node(k); return v1 + v2; } } public long get_minus(int a, int b, int k, int l, int r){ evaluate_node(k, l, r); if(r <= a || b <= l){ return 0; }else if(a <= l && r <= b){ return minus_sum[k]; }else { long v1 = get_minus(a, b, k * 2 + 1, l, (l + r) / 2); long v2 = get_minus(a, b, k * 2 + 2, (l + r) / 2, r); update_node(k); return v1 + v2; } } } public static void main(String[] args) { Scanner sc = new Scanner(System.in); final int N = sc.nextInt(); final int Q = sc.nextInt(); long a_score = 0, b_score = 0; LazySegTree seg = new LazySegTree(N); for(int i = 0; i < Q; i++){ final int x = sc.nextInt(); final int l = sc.nextInt(); final int r = sc.nextInt() + 1; if(x == 0){ final long a_team = seg.get_plus(l, r, 0, 0, seg.n); final long b_team = -seg.get_minus(l, r, 0, 0, seg.n); if(a_team > b_team){ a_score += a_team; }else if(a_team < b_team){ b_score += b_team; } //System.out.println(a_team + " " + b_team); }else if(x == 1){ seg.update( 1, l, r, 0, 0, seg.n); }else if(x == 2){ seg.update(-1, l, r, 0, 0, seg.n); } //System.out.println(i + " plus " + seg.get_plus(0, N, 0, 0, seg.n)); //System.out.println(i + " minus " + seg.get_minus(0, N, 0, 0, seg.n)); } a_score += seg.get_plus(0, N, 0, 0, seg.n); b_score -= seg.get_minus(0, N, 0, 0, seg.n); System.out.println(a_score + " " + b_score); } }