#include<bits/stdc++.h>
using namespace std;
const int M=1e5+50;
struct tree{
int l,r,sum,shumiao;
bool ks,zs;
}e[M];
int l,n,t,x,y,all,ans1,ans2;
inline void build(int l,int r,int root)
{
e[root].l=l,e[root].r=r;
if(l==r)
{
e[root].sum=1;
return ;
}
int mid=(l+r)>>1;
build(l,mid,root<<1);
build(mid+1,r,(root<<1)|1);
e[root].sum=e[root<<1].sum+e[(root<<1)|1].sum;
return ;
}
inline void push_down1(int root)
{
int l=(root<<1),r=((root<<1)|1);
e[l].ks=true;e[r].ks=true;
e[l].shumiao=0;e[r].shumiao=0;
e[l].sum=0;e[r].sum=0;
e[root].ks=false;
return ;
}
inline void push_down2(int root)
{
int l=(root<<1),r=((root<<1)|1);
e[l].zs=true;e[r].zs=true;
e[l].shumiao=e[l].r-e[l].l+1-e[l].sum;
e[r].shumiao=e[r].r-e[r].l+1-e[r].sum;
e[root].zs=false;
return ;
}
inline void kanshu(int l,int r,int root)
{
if(l>y||r<x) return ;
if(l>=x&&r<=y)
{
ans2+=e[root].shumiao;
e[root].shumiao=0;
e[root].sum=0;
e[root].ks=true;
return ;
}
int mid=(l+r)>>1;
if(e[root].ks) push_down1(root);
if(e[root].zs) push_down2(root);
kanshu(l,mid,root<<1);
kanshu(mid+1,r,(root<<1)|1);
e[root].sum=e[root<<1].sum+e[(root<<1)|1].sum;
e[root].shumiao=e[root<<1].shumiao+e[(root<<1)|1].shumiao;
return ;
}
inline void zhongshu(int l,int r,int root)
{
if(l>y||r<x) return ;
if(l>=x&&r<=y)
{
ans1+=(r-l+1)-e[root].sum-e[root].shumiao;
e[root].shumiao=(r-l+1)-e[root].sum;
e[root].zs=true;
return ;
}
int mid=(l+r)>>1;
if(e[root].ks) push_down1(root);
if(e[root].zs) push_down2(root);
zhongshu(l,mid,root<<1);
zhongshu(mid+1,r,(root<<1)|1);
e[root].shumiao=e[root<<1].shumiao+e[(root<<1)|1].shumiao;
e[root].sum=e[root<<1].sum+e[(root<<1)|1].sum;
return ;
}
int main()
{
scanf("%d%d",&l,&n);
build(0,l,1);
//for(int i=1;i<=4*l;i++) cout<<e[i].sum<<" ";
for(int i=1;i<=n;i++)
{
scanf("%d%d%d",&t,&x,&y);
if(y<x) swap(x,y);
if(t==1)
{
zhongshu(0,l,1);
}
else
{
kanshu(0,l,1);
}
/*printf("%d\n",ans1-ans2);
printf("%d\n",ans2);*/
}
printf("%d\n",ans1-ans2);
printf("%d",ans2);
return 0;
}