using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray(); static int[] NMi => ReadLine().Split().Select(c => int.Parse(c) - 1).ToArray(); public static void Main() { Solve(); } static void Solve() { var c = NList; var (n, q) = (c[0], c[1]); var a = NList; var b = NList; var ans = Move(n, q, a, b); WriteLine(ans); } static string Move(int n, int q, int[] _a, int[] _b) { var a = _a.Select(ai => ai - 1).ToArray(); var b = _b.Select(bi => bi - 1).ToArray(); var dp = Enumerable.Repeat(true, n).ToArray(); var cand = new List(); var moves = new List<(int from, int to)>[q]; for (var i = 0; i < moves.Length; ++i) moves[i] = new List<(int from, int to)>(); for (var i = 0; i < q; ++i) { var ncand = new List(); foreach (var ci in cand) { if (dp[ci] || a[i] == ci || b[i] == ci) continue; if (ci > 0 && dp[ci - 1]) { moves[i].Add((ci - 1, ci)); ncand.Add(ci - 1); if (ci + 1 < n) ncand.Add(ci + 1); } else if (ci + 1 < n && dp[ci + 1]) { moves[i].Add((ci + 1, ci)); ncand.Add(ci + 1); if (ci > 0) ncand.Add(ci - 1); } } foreach (var mi in moves[i]) dp[mi.to] = true; dp[a[i]] = false; ncand.Add(a[i]); dp[b[i]] = false; ncand.Add(b[i]); cand = ncand; } if (dp.Any(f => f)) { var ans = new List(); var pos = 0; for (var i = 0; i < dp.Length; ++i) if (dp[i]) { pos = i; break; } ans.Add(pos); for (var i = q - 1; i >= 0; --i) { for (var j = 0; j < moves[i].Count; ++j) if (moves[i][j].to == pos) { pos = moves[i][j].from; break; } ans.Add(pos); } ans.Reverse(); return $"YES\n{string.Join("\n", ans.Select(ai => ai + 1))}"; } else { return "NO"; } } }