#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; int inputValue(){ int a; cin >> a; return a; } template void output(T a, int precision) { if(precision > 0){ cout << fixed << setprecision(precision) << a << "\n"; } else{ cout << a << "\n"; } } 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; }