#include #define rep(i,a,b) for(int i=a;i struct LazySegTree { // [L,R) #define def 0 #define ldef -1 V comp(V l, V r) { return l + r; } void setLazy(int i, V v) { lazy[i] = v; } void push(int k, int l, int r) { if (lazy[k] != ldef) { // modify------------------------------ dat[k] = lazy[k] * (r - l); // ------------------------------------ if (r - l > 1) { setLazy(k * 2 + 1, lazy[k]); setLazy(k * 2 + 2, lazy[k]); } setLazy(k, ldef); } } vector dat, lazy; LazySegTree() { dat.resize(NV * 2, def); lazy.resize(NV * 2, ldef); } void update(int a, int b, V v, int k, int l, int r) { push(k, l, r); if (r <= a || b <= l) return; if (a <= l && r <= b) { setLazy(k, v); push(k, l, r); } else { update(a, b, v, k * 2 + 1, l, (l + r) / 2); update(a, b, v, k * 2 + 2, (l + r) / 2, r); dat[k] = comp(dat[k * 2 + 1], dat[k * 2 + 2]); } } V get(int a, int b, int k, int l, int r) { push(k, l, r); if (r <= a || b <= l) return def; if (a <= l && r <= b) return dat[k]; auto x = get(a, b, k * 2 + 1, l, (l + r) / 2); auto y = get(a, b, k * 2 + 2, (l + r) / 2, r); return comp(x, y); } void update(int a, int b, V v) { update(a, b, v, 0, 0, NV); } V get(int a, int b) { return get(a, b, 0, 0, NV); } }; /*---------------------------------------------------------------------------------------------------             ∧_∧       ∧_∧  (´<_` )  Welcome to My Coding Space!      ( ´_ゝ`) /  ⌒i     /   \    | |     /   / ̄ ̄ ̄ ̄/  |   __(__ニつ/  _/ .| .|____      \/____/ (u ⊃ ---------------------------------------------------------------------------------------------------*/ int N, Q; LazySegTree st; //--------------------------------------------------------------------------------------------------- ll e = 1000000; void _main() { cin >> N >> Q; ll A = 0, B = 0; rep(q, 0, Q) { int x, l, r; cin >> x >> l >> r; r++; if (x == 0) { ll sm = st.get(l, r); ll a = sm % e; ll b = sm / e; if (a < b) B += b; else if (a > b) A += a; } else if (x == 1) st.update(l, r, 1); else st.update(l, r, e); } //rep(i, 0, N) printf("[%lld]\n", st.get(i, i + 1)); ll sm = st.get(0, N); //cout << sm << endl; //rep(i, 0, N) cout << st.get(0, i + 1) << endl; ll a = sm % e; ll b = sm / e; A += a; B += b; printf("%lld %lld\n", A, B); }