#include using namespace std; #define ALL(x) begin(x),end(x) #define rep(i,n) for(int i=0;i<(n);i++) #define debug(v) cout<<#v<<":";for(auto x:v){cout<bool chmax(T &a,const T &b){if(abool chmin(T &a,const T &b){if(b ostream &operator<<(ostream &os,const vector&v){ for(int i=0;i<(int)v.size();i++) os< istream &operator>>(istream &is,vector&v){ for(T &x:v)is>>x; return is; } const int SZ=100000; signed main(){ int N,M;cin>>N>>M; vector A(M),B(M); cin>>A>>B; bitset P; P=~P; rep(i,N){ P=(P>>1)|P|(P<<1); bitset cur; cur=~cur; cur[A[i]-1]=0; cur[B[i]-1]=0; auto need=(cur>>1)|cur|(cur<<1); P&=need; P&=cur; } int last=-1; rep(i,N){ if(P[i]) last=i; } if(last<0){ cout<<"NO"<