#include #include using namespace std; int N,Q; int A[1<<17],B[1<<17]; int L[1<<17],R[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]); L[i]=L[i+1]-1; if(A[i]==L[i+1]+1||B[i]==L[i+1]+1)L[i]++; if(A[i]==L[i+1]+1&&B[i]==L[i+1]+2)L[i]++; if(L[i]<0)L[i]=0; R[i]=R[i+1]+1; if(A[i]==R[i+1]-1||B[i]==R[i+1]-1)R[i]--; if(A[i]==R[i+1]-2&&B[i]==R[i+1]-1)R[i]--; if(R[i]>N+1)R[i]=N+1; } if(L[0]+1=R[i])pos--; else if(pos==A[i]||pos==B[i]) { pos--; if(pos<=L[i]||pos==A[i]||pos==B[i])pos+=2; } cout<