import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop; void main() { auto N = readln.chomp.to!int; auto Q = readln.chomp.to!int; auto st = new LazySegmentTree!(int, (a,b)=>a+b)(N); auto st2 = new LazySegmentTree!(int, (a,b)=>a+b)(N); long score1 = 0; long score2 = 0; foreach (q; 0..Q) { auto s = readln.split.map!(to!int); auto x = s[0]; auto l = s[1]; auto r = s[2]; if (x == 0) { auto used = st2.getVal(l, r); auto m = st.getVal(l, r); auto a = (used + m) / 2; auto b = used - a; if (m > 0) score1 += a; if (m < 0) score2 += b; } else if (x == 1) { st.assign(l, r, 1); st2.assign(l, r, 1); } else if (x == 2) { st.assign(l, r, -1); st2.assign(l, r, 1); } } auto used = st2.getVal(0, N-1); auto m = st.getVal(0, N-1); auto a = (used + m) / 2; auto b = used - a; score1 += a; score2 += b; writeln(score1, " ", score2); } class LazySegmentTree(T, alias op) { T[] table; T[] lazy_; int size; this(int n) { assert(bsr(n) < 29); size = 1 << (bsr(n) + 2); table = new T[](size); lazy_ = new T[](size); fill(table, 0); fill(lazy_, 0); } void assign(int left, int right, T num) { return assign(left, right, num, 0, 0, size/2-1); } void assign(int left, int right, T num, int i, int seg_left, int seg_right) { if (left > seg_right || right < seg_left) { return; } if (left <= seg_left && seg_right <= right) { lazy_[i] = num; return; } else { if (lazy_[i] != 0) { lazy_[i*2+1] = lazy_[i]; lazy_[i*2+2] = lazy_[i]; lazy_[i] = 0; } assign(left, right, num, i*2+1, seg_left, (seg_left+seg_right)/2); assign(left, right, num, i*2+2, (seg_left+seg_right)/2+1, seg_right); } } T getVal(int left, int right) { return getVal(left, right, 0, 0, size/2-1); } T getVal(int left, int right, int i, int seg_left, int seg_right) { if (left > seg_right || right < seg_left) { return 0; } else if (seg_left == seg_right) { if (lazy_[i] != 0) { table[i] = lazy_[i]; lazy_[i] = 0; } return table[i]; } if (lazy_[i] != 0) { lazy_[i*2+1] = lazy_[i]; lazy_[i*2+2] = lazy_[i]; lazy_[i] = 0; } table[i] = op(getVal(left, right, i*2+1, seg_left, (seg_left+seg_right)/2), getVal(left, right, i*2+2, (seg_left+seg_right)/2+1, seg_right)); return table[i]; } }