n,Q=map(int,input().split()) a=list(map(int,input().split())) b=list(map(int,input().split())) s=set() x=[[1,n] for i in range(Q+1)] for i in range(Q-1,-1,-1): q,w=a[i],b[i] s.add((i,q));s.add((i,w)) if x[i+1][0]==q and q+1==w: x[i][0]=w if x[i+1][1]==w and w-1==q: x[i][1]=q if x[0][0]>x[0][1]: print("NO") else: print("YES") m=x[0][0] print(m) for i in range(1,Q+1): for j in range(-1,2): if x[i][0]<=m+j<=x[i][1] and (i-1,m+j) not in s: m+=j break print(m)