#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define MAX 200002 int n; int w; struct st{ int sum = 0; int lazy = -1; int a = 0; int b = 0; }; st seg[MAX * 4]; void update(int a){ if (seg[a].lazy != -1){ if (seg[a].lazy == 0){ seg[a].a = seg[a].sum; seg[a].b = 0; } else{ seg[a].a = 0; seg[a].b = seg[a].sum; } seg[a * 2 + 1].lazy = seg[a].lazy; seg[a * 2 + 2].lazy = seg[a].lazy; seg[a].lazy = -1; } } inline void init(int b, int l, int r){ seg[b].sum = r - l; if (l + 1 == r){ return; } init(b * 2 + 1, l, (l + r) >> 1); init(b * 2 + 2, (l + r) >> 1, r); } inline void add(int b, int l, int r, int ll, int rr,int x){ update(b); if (ll <= l&&r <= rr){ seg[b].lazy = x; update(b); return; } if (r<=ll || rr <= l){ return; } add(b * 2 + 1, l, (l + r) >> 1, ll, rr, x); add(b * 2 + 2, (l + r) >> 1, r, ll, rr, x); seg[b].a = seg[b * 2 + 1].a + seg[b * 2 + 2].a; seg[b].b = seg[b * 2 + 1].b + seg[b * 2 + 2].b; seg[b].lazy = -1; } inline pair q(int b, int l, int r, int ll, int rr){ update(b); if (r <= ll || rr <= l){ return make_pair(0, 0); } if (ll <= l&&r <= rr){ return make_pair(seg[b].a, seg[b].b); } pair R; R = q(b * 2 + 1, l, (l + r) >> 1, ll, rr); pair f = q(b * 2 + 2, (l + r) >> 1, r, ll, rr); R.first += f.first; R.second += f.second; return R; } int main(){ scanf("%d", &n); int qq; scanf("%d", &qq); long long int ans = 0; long long int ans1 = 0; init(0, 0, n); while (qq--){ int ty; scanf("%d", &ty); if (ty == 0){ int l, r; scanf("%d%d", &l, &r); pair k = q(0, 0, n, l, r + 1); if (k.first == k.second){ continue; } if (k.first > k.second){ ans += (long long int)(k.first); } else{ ans1 += (long long int)(k.second); } continue; } int l, r; scanf("%d%d", &l, &r); if (ty == 1){ add(0, 0, n, l, r + 1, 0); } else{ add(0, 0, n, l, r + 1, 1); } } pair k = q(0, 0, n, 0, n); ans += (long long int)(k.first); ans1 += (long long int)(k.second); printf("%lld %lld\n", ans, ans1); return 0; }