#include #include #include using namespace std; using ll = long long; using ull = unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) int N,Q; vector A; vector B; vector L; vector R; int main(){ cin >> N >> Q; A.resize(Q); rep(i,Q){ cin >> A[i]; A[i]--; } B.resize(Q); rep(i,Q){ cin >> B[i]; B[i]--; } rep(i,Q) if(A[i] > B[i]) swap(A[i],B[i]); L.assign(Q+1,0); R.assign(Q+1,N-1); bool done = false; while(!done){ done = true; for(int i=Q-1; i>=0; i--){ L[i] = max(L[i],L[i+1]-1); if(L[i] == A[i]){ L[i]++; done=false; } if(L[i] == B[i]){ L[i]++; done=false; } R[i] = min(R[i],R[i+1]+1); if(R[i] == B[i]){ R[i]--; done=false; } if(R[i] == A[i]){ R[i]--; done=false; } } for(int i=0; i R[i]){ cout << "NO\n"; return 0; } } vector ans; ans.push_back(L[0]+1); rep(i,Q) ans.push_back(L[i]+1); cout << "YES\n"; for(int a : ans) cout << a << "\n"; return 0; } struct ios_do_not_sync{ ios_do_not_sync(){ ios::sync_with_stdio(false); cin.tie(nullptr); } } ios_do_not_sync_instance;