#include "bits/stdc++.h" using namespace std; #define DEBUG(x) cout<<#x<<": "< #define vl vector #define vii vector< vector > #define vll vector< vector > #define vs vector #define pii pair #define pis pair #define psi pair #define pll pair #define fi first #define se second #define rep(i,n) for(int i=0;i<(int)(n);i++) #define rep1(i,n) for(int i=1;i<=(int)(n);i++) #define all(c) c.begin(),c.end() const int inf = 1000000001; const ll INF = 2e18 * 2; #define MOD 1000000007 #define mod 1000000009 #define pi 3.14159265358979323846 #define Sp(p) cout<= 0; i--) { node[i] = node[i * 2 + 1] + node[i * 2 + 2]; } } // k番目のノードについて遅延評価を行う inline void eval(int k, int l, int r) { if (lazy[k] != -2 * INF) { node[k] = (r - l) * lazy[k]; if (r - l > 1) { lazy[2 * k + 1] = lazy[k]; ///// lazy[2 * k + 2] = lazy[k]; ///// } lazy[k] = -2 * INF; } } // [a, b)をxにする void update(int a, int b, ll x, int k, int l, int r) { // k 番目のノードに対して遅延評価を行う eval(k, l, r); if (b <= l || r <= a) return; if (a <= l && r <= b) { lazy[k] = x; eval(k, l, r); } else { update(a, b, x, 2 * k + 1, l, (l + r) / 2); update(a, b, x, 2 * k + 2, (l + r) / 2, r); node[k] = node[2 * k + 1] + node[2 * k + 2]; } } ll getsum(int a, int b, int k, int l, int r) { eval(k, l, r); if (b <= l || r <= a) return 0; if (a <= l && r <= b) return node[k]; ll resl = getsum(a, b, 2 * k + 1, l, (l + r) / 2); ll resr = getsum(a, b, 2 * k + 2, (l + r) / 2, r); return resl + resr; } }; int main() { int n, q, i, j; cin >> n >> q; vl temp(n); LazySegmentTree lst1(temp), lst2(temp); ll scorea = 0, scoreb = 0; for (int unko = 0; unko < q; unko++) { int x, l, r; cin >> x >> l >> r; if (x == 0) { ll score1 = lst1.getsum(l, r + 1, 0, 0, lst1.n); ll score2 = lst2.getsum(l, r + 1, 0, 0, lst2.n); if (score1 > score2) { scorea += score1; } else if (score1 < score2) { scoreb += score2; } } else { if (x == 1) { lst1.update(l, r + 1, 1, 0, 0, lst1.n); lst2.update(l, r + 1, 0, 0, 0, lst2.n); } else { lst1.update(l, r + 1, 0, 0, 0, lst1.n); lst2.update(l, r + 1, 1, 0, 0, lst2.n); } } } scorea += lst1.getsum(0, lst1.n, 0, 0, lst1.n); scoreb += lst2.getsum(0, lst2.n, 0, 0, lst2.n); cout << scorea << " " << scoreb << endl; }