N,M=map(int,input().split()) query=[] for m in range(M): L,R=map(int,input().split()) query.append((R,L)) query.sort() queue=[] for R,L in query: if not queue or queue[-1]