#include using namespace std; const int MAXN = int( 1e5 ); int N; int Q; signed main() { ios::sync_with_stdio( 0 ); cin >> N; cin >> Q; bitset< MAXN > team[ 2 ], mask; long long ans[ 2 ] = { 0, 0 }; for( int qi = 0; qi < Q; ++qi ) { int x, l, r; cin >> x >> l >> r; mask.reset(); mask.flip(); mask >>= MAXN - ( r - l + 1 ); mask <<= l; if( x == 0 ) { int ca = ( mask & team[ 0 ] ).count(); int cb = ( mask & team[ 1 ] ).count(); if( ca == cb ) continue; if( ca > cb ) { ans[ 0 ] += ca; } else { ans[ 1 ] += cb; } } else { team[ x - 1 ] |= mask; mask.flip(); team[ x - 1 ^ 1 ] &= mask; } } ans[ 0 ] += team[ 0 ].count(); ans[ 1 ] += team[ 1 ].count(); cout << ans[ 0 ] << " " << ans[ 1 ] << endl; return 0; }