#include using namespace std; #define rep(i,a,b) for(int i=a;i data; int seg_size; LazySeg_sum(int n) { for (seg_size = 1; seg_size < n; seg_size *= 2); data.assign(seg_size * 2, Data()); } ll set(int a, int b, ll x, int l = 0, int r = -1, int k = 0) { if (r == -1) r = seg_size - 1; if (a <= l && r <= b) { data[k].set_data(x, 0); return data[k].calc_sum(l, r); } if (r < a || b < l) return data[k].calc_sum(l, r); if (data[k].valset) { data[k * 2 + 1].set_data(data[k].val, data[k].add); data[k * 2 + 2].set_data(data[k].val, data[k].add); } data[k].add = 0; data[k].valset = false; data[k].sum = set(a, b, x, l, (l + r) / 2, k * 2 + 1) + set(a, b, x, (l + r) / 2 + 1, r, k * 2 + 2); return data[k].calc_sum(l, r); } ll add(int a, int b, ll x, int l = 0, int r = -1, int k = 0) { if (r == -1) r = seg_size - 1; if (a <= l && r <= b) { data[k].add += x; return data[k].calc_sum(l, r); } if (r < a || b < l) return 0; if (data[k].valset) { data[k * 2 + 1].set_data(data[k].val, 0); data[k * 2 + 2].set_data(data[k].val, 0); data[k].valset = false; } data[k].sum = add(a, b, x, l, (l + r) / 2, k * 2 + 1) + add(a, b, x, (l + r) / 2 + 1, r, k * 2 + 2); return data[k].calc_sum(l, r); } ll query(int a, int b, int l = 0, int r = -1, int k = 0) { if (r == -1) r = seg_size - 1; if (r < a || b < l) return 0; if ((a <= l && r <= b) || data[k].valset) { return data[k].calc_sum(max(a, l), min(b, r)); } return query(a, b, l, (l + r) / 2, k * 2 + 1) + query(a, b, (l + r) / 2 + 1, r, k * 2 + 2) + data[k].add * (min(b, r) - max(a, l) + 1); } }; //----------------------------------------------------------------------------------- ll e = 1000000; int main() { cin >> N >> Q; LazySeg_sum st(N); ll A = 0, B = 0; rep(q, 0, Q) { int x, l, r; scanf("%d%d%d", &x, &l, &r); if (x == 0) { ll sm = st.query(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.set(l, r, 1); else st.set(l, r, e); } //rep(i, 0, N) printf("[%lld]\n", st.query(i, i + 1)); ll sm = st.query(0, N - 1); //cout << sm << endl; ll a = sm % e; ll b = sm / e; A += a; B += b; printf("%lld %lld\n", A, B); }