#define _USE_MATH_DEFINES #include using namespace std; #define FOR(i,m,n) for(int i=(m);i<(n);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() using ll = long long; constexpr int INF = 0x3f3f3f3f; constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL; constexpr double EPS = 1e-8; constexpr int MOD = 1000000007; // constexpr int MOD = 998244353; constexpr int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1}; constexpr int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1}; template inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; } template inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; } struct IOSetup { IOSetup() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << fixed << setprecision(20); } } iosetup; int main() { constexpr int M = 100000; int n, q; cin >> n >> q; vector a(q), b(q); REP(i, q) cin >> a[i], --a[i]; REP(i, q) cin >> b[i], --b[i]; REP(i, q) { if (a[i] > b[i]) swap(a[i], b[i]); } bitset reach(0); REP(i, n) reach.set(i); REP(i, q) { reach = (reach << 1) | reach | (reach >> 1); if (n < M) reach.reset(n); reach.reset(a[i]); reach.reset(b[i]); } if (reach.none()) { cout << "NO\n"; return 0; } vector k; auto f = [&](auto &&f, int i, int g) -> void { k.emplace_back(g); if (i == -1) { cout << "YES\n" << g + 1 << '\n'; assert(k.size() == q); reverse(ALL(k)); REP(i, q) { assert(k[i] != a[i] && k[i] != b[i]); cout << k[i] + 1 << '\n'; } exit(0); } if (a[i] == g) { if (g > 0) f(f, i - 1, g - 1); if (a[i] + 1 < b[i]) f(f, i - 1, g + 1); } else if (b[i] == g) { if (g + 1 < n) f(f, i - 1, g + 1); if (a[i] + 1 < b[i]) f(f, i - 1, g - 1); } else { if (g > 0 && a[i] != g - 1 && b[i] != g - 1) f(f, i - 1, g - 1); f(f, i - 1, g); if (g + 1 < n && a[i] != g + 1 && b[i] != g + 1) f(f, i - 1, g + 1); } k.pop_back(); }; REP(i, n) { if (reach[i]) f(f, q - 2, i); } assert(false); }