n, q = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) segs = [None] * (q + 1) segs[q] = [[0, 1], [n + 1, n + 2]] for i in reversed(range(q)): segs[i] = [] for seg in segs[i + 1]: l, r = seg if 0 < l < n + 1: l += 1 if 1 < r < n + 2: r -= 1 if l < r: segs[i].append([l, r]) for j in range(len(segs[i]) - 1): if segs[i][j][1] <= a[i] < segs[i][j + 1][0]: if segs[i][j][1] == a[i]: if a[i] + 1 == segs[i][j + 1][0]: print('NO') exit() segs[i][j][1] += 1 elif a[i] + 1 == segs[i][j + 1][0]: segs[i][j + 1][0] -= 1 else: segs[i].append([a[i], a[i] + 1]) if a[i] == b[i]: continue if segs[i][j][1] <= b[i] < segs[i][j + 1][0]: if segs[i][j][1] == b[i]: if b[i] + 1 == segs[i][j + 1][0]: print('NO') exit() segs[i][j][1] += 1 elif b[i] + 1 == segs[i][j + 1][0]: segs[i][j + 1][0] -= 1 else: segs[i].append([b[i], b[i] + 1]) segs[i].sort() ans = [] s = segs[0][0][1] ans.append(s) for i in range(q): for j in range(len(segs[i]) - 1): if abs(segs[i][j][1] - s) <= 1 and segs[i][j][1] != segs[i][j + 1][0]: s = segs[i][j][1] ans.append(s) break else: print('NO') exit() print('YES') for x in ans: print(x)