n,q=map(int,input().split()) p=[0]*n c=0 anss=[] for i in range(q): l,r=map(int,input().split()) for j in range(l-1,r): if p[j]==0: c+=1 p[j]=1 elif p[j]==1: c-=1 p[j]=0 anss.append(c) for x in anss: print(x)