void main(){ import std.stdio, std.string, std.conv, std.algorithm; int n; rd(n); int q; rd(q); long a=0, b=0; auto treeA=new SquareRootDecomposition(n), treeB=new SquareRootDecomposition(n); while(q--){ int t, l, r; rd(t, l, r); if(t==0){ auto cntA=treeA.sum(l, r+1), cntB=treeB.sum(l, r+1); if(cntA==cntB) continue; (cntA>cntB ? a : b)+=max(cntA, cntB); }else if(t==1){ treeA.update(l, r+1, 1); treeB.update(l, r+1, 0); }else if(t==2){ treeA.update(l, r+1, 0); treeB.update(l, r+1, 1); } } a+=treeA.sum(0, n); b+=treeB.sum(0, n); writeln(a, " ", b); } class SquareRootDecomposition{ import std.algorithm; int D=1, nil=-1; int[] val, buc, laz; this(int n){ while(D*D