#include #include #include #include #include #include #include #include #include #include #include #include #include #define repd(i,a,b) for (int i=(a);i<(b);i++) #define rep(i,n) repd(i,0,n) #define var auto #define mod 1000000007 #define inf 2147483647 #define nil -1 typedef long long ll; using namespace std; inline int inputValue(){ int a; cin >> a; return a; } template inline void output(T a, int precision) { if(precision > 0){ cout << fixed << setprecision(precision) << a << "\n"; } else{ cout << a << "\n"; } } class rmq { private: int n; int sz; public: vector v; rmq(int a){ n = 1; for(; n * 2 < a;){ n *= 2; } sz = n * 2; v.resize(4 * n - 1, inf); } void update(int i, ll x){ i += sz - 1; v[i] = x; while(i > 0){ i = (i - 1) / 2; v[i] = min(v[2 * i + 1], v[2 * i + 2]); } } ll query_(int a, int b, int k, int l, int r){ if(r <= a || b <= l) return inf; if(a <= l && r <= b) return v[k]; else{ ll vl = query_(a, b, k * 2 + 1, l, (l + r) / 2); ll vr = query_(a, b, k * 2 + 2, (l + r) / 2, r); return min(vl, vr); } } ll query(int a, int b){ return query_(a, b, 0, 0, sz); } }; int sz; class segtree_lazy{ private: int n; // static int sz; public: vector isfull, to; // isfull : 1 / 0 / -1 : full / empty / mixed, to: count segtree_lazy(int a){ n = 1; while(n < a){ n *= 2; } sz = n; isfull.resize(2 * n - 1, 0); // 0-indexed to.resize(2 * n - 1, 0); // 0-indexed } int sum(int x, int y, int l = 0, int r = sz, int k = 0){ // [x, y) if(r <= x || y <= l) return 0; if(x <= l && r <= y) return to[k]; x = max(x, l); y = min(y, r); if(isfull[k] >= 0) return isfull[k] ? (y - x) : 0; return sum(x, y, l, (l + r) / 2, k * 2 + 1) + sum(x, y, (l + r) / 2, r, k * 2 + 2); } void update(int x, int y, int v, int l = 0, int r = sz, int k = 0) { // [x, y) if(x <= l && r <= y) { isfull[k] = v; to[k] = isfull[k] ? (r - l) : 0; } else if(l < y && x < r) { if(isfull[k] >= 0) { isfull[k * 2 + 1] = isfull[k * 2 + 2] = isfull[k]; to[k * 2 + 1] = to[k * 2 + 2] = isfull[k] ? (r - l) / 2 : 0; isfull[k] = -1; } update(x, y, v, l, (l + r) / 2, k * 2 + 1); update(x, y, v, (l + r) / 2, r, k * 2 + 2); to[k] = to[k * 2 + 1] + to[k * 2 + 2]; } } }; // end of template int main() { cin.tie(0); // source code int N = inputValue(); int Q = inputValue(); segtree_lazy A(N), B(N); int ptA = 0; int ptB = 0; rep(i, Q){ int x = inputValue(); int l = inputValue(); int r = inputValue() + 1; if (x == 1) { A.update(l, r, 1); B.update(l, r, 0); } else if (x == 2){ A.update(l, r, 0); B.update(l, r, 1); } else{ int tptA = A.sum(l, r); int tptB = B.sum(l, r); if (tptA > tptB) { ptA += tptA; } else if (tptA < tptB){ ptB += tptB; } } } ptA += A.sum(0, N); ptB += B.sum(0, N); cout << ptA << " " << ptB << endl; return 0; }