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 j in range(len(segs[i + 1])): l, r = segs[i + 1][j] if 0 < l < n + 1 and j != 0 and segs[i + 1][j - 1][1] != l: l += 1 if 1 < r < n + 2 and j != len(segs[i + 1]) - 1 and r != segs[i + 1][j + 1][0]: 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]: segs[i].append([a[i], a[i] + 1]) break segs[i].sort() if a[i] == b[i]: continue for j in range(len(segs[i]) - 1): if segs[i][j][1] <= b[i] < segs[i][j + 1][0]: segs[i].append([b[i], b[i] + 1]) break 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)