#include using namespace std; struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_; #define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i=i##_begin_;i--) #define REP(i, n) FOR(i,0,n) #define IREP(i, n) IFOR(i,0,n) template istream &operator>>(istream &is, vector &vec){ for (auto &v : vec) is >> v; return is; } template ostream &operator<<(ostream &os, const vector &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; } #define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl; void output(vector v) { for (auto x : v) cout << x << ' '; cout << '\n'; exit(0); } int main() { int N, P, Q; cin >> N >> P >> Q; vector A(N); cin >> A; set s; bool p = false, q = false; IREP(i, N) { int T = A[i]; if (T == P) p = true; if (T == Q) q = true; s.insert(T); if (p and q and s.size() == 2 and P > Q) { A[i - 2] = P, A[i - 1] = Q; output(A); } if (p and q and *prev(s.end()) > A[i] and s.size() > 2) { int x = *s.upper_bound(T); if (x == Q and p) x = *next(s.upper_bound(T)); A[i] = x; s.erase(x); if (x == P) p = false; FOR(j, i + 1, N) { A[j] = *s.begin(); if (A[j] == Q and p) A[j] = *next(s.begin()); s.erase(A[j]); if (A[j] == P) p = false; } output(A); } } puts("-1"); }