#include<bits/stdc++.h>
using namespace std;
long long n,m,a[10001],b[10001],c[10001],d[10001],l,t,x,y,k,s;
int main(){
cin>>n>>m;
for(int i=1;i<=n+1;i++)
a[i]=1;
for(int i=1;i<=m;i++)
cin>>b[i]>>c[i]>>d[i];
for(int i=1;i<=m;i++)
{
if(b[i]==0)
{
for(int j=c[i];j<=d[i];j++)
{
if(a[j]==2)
{
s++;
a[j]=0;
}
else
a[j]=0;
}
}
else
{
for(int j=c[i];j<=d[i];j++)
{
if(a[j]==0)
a[j]=2;
}
}
}
for(int i=1;i<=n+1;i++)
{
if(a[i]==2)
t++;
}
cout<<t<<endl<<s;
return 0;
}