#include #include using namespace std; int N,Q; int A[1<<17],B[1<<17]; int L[1<<17],R[1<<17]; int L2[1<<17],R2[1<<17]; main() { cin>>N>>Q; for(int i=0;i>A[i]; for(int i=0;i>B[i]; L[Q]=0,R[Q]=N+1; for(int i=Q;i--;) { if(A[i]>B[i])swap(A[i],B[i]); int l=L[i+1]-1,r=R[i+1]+1; if(l<0)l=0; if(r>N+1)r=N+1; if(A[i]==l+1||B[i]==l+1) { l++; if(A[i]==l&&B[i]==l+1)l++; } if(A[i]==r-1||B[i]==r-1) { r--; if(A[i]==r-1&&B[i]==r)r--; } if(l+1>=r) { cout<<"NO"<=R[i])continue; if(v==A[i]||v==B[i])continue; nxt=v; break; } pos=nxt; cout<