import std.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto n = readln.chomp.to!size_t; auto q = readln.chomp.to!size_t; auto sa = SegmentTree(n), sb = SegmentTree(n); auto pa = 0L, pb = 0L; foreach (_; 0..q) { auto rd = readln.split, x = rd[0], l = rd[1].to!size_t, r = rd[2].to!size_t + 1; switch (x) { case "0": auto ca = sa[l..r], cb = sb[l..r]; if (ca > cb) pa += ca; if (ca < cb) pb += cb; break; case "1": sa[l..r] = true; sb[l..r] = false; break; case "2": sa[l..r] = false; sb[l..r] = true; break; default: assert(0); } } pa += sa[0..$]; pb += sb[0..$]; writeln(pa, " ", pb); } struct SegmentTree { import core.bitop, std.conv; const size_t n, an; bool[] buf, prop; this(size_t n) { this.n = n; an = (1 << ((n - 1).bsr + 1)); buf = new bool[](an * 2); prop = new bool[](an * 2); prop[an..$] = true; } void propagate(size_t k) { if (k >= an || !prop[k]) return; buf[k*2] = buf[k*2+1] = buf[k]; prop[k*2] = prop[k*2+1] = true; prop[k] = false; } void opSliceAssign(bool val, size_t l, size_t r) { fill(val, l, r, 1, 0, an); } void fill(bool val, size_t l, size_t r, size_t k, size_t nl, size_t nr) { if (nr <= l || r <= nl) return; if (l <= nl && nr <= r) { buf[k] = val; prop[k] = true; return; } propagate(k); auto nm = (nl + nr) / 2; fill(val, l, r, k*2, nl, nm); fill(val, l, r, k*2+1, nm, nr); } int opSlice(size_t l, size_t r) { return count(l, r, 1, 0, an); } int count(size_t l, size_t r, size_t k, size_t nl, size_t nr) { if (nr <= l || r <= nl) return 0; if (l <= nl && nr <= r && prop[k]) return (nr - nl).to!int * (buf[k] ? 1 : 0); propagate(k); auto nm = (nl + nr) / 2; auto vl = count(l, r, k*2, nl, nm); auto vr = count(l, r, k*2+1, nm, nr); return vl + vr; } pure size_t opDollar() const { return n; } }