#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 in() { int x; cin >> x; return x; } int main() { const int N = in(), P = in(), Q = in(); vector A(N); cin >> A; int ip = 0, iq = 0; while (A[ip] != P) ip++; while (A[iq] != Q) iq++; bool fok = (ip < iq); set s; bool fp = false, fq = false; if (P > Q and A[N - 2] == Q and A[N - 1] == P) { A[N - 2] = P, A[N - 1] = Q; output(A); } IREP(i, N) { if (A[i] == P) fp = true; if (A[i] == Q) fq = true; s.insert(A[i]); if ((fok or fq) and *prev(s.end()) > A[i]) { auto itr = s.upper_bound(A[i]); if (fp and *itr == Q) itr = next(itr); if (itr == s.end()) continue; int x = *itr; s.erase(itr); A[i] = x; s.erase(x); if (x == P) fp = false; FOR(j, i + 1, N) { auto itr = s.begin(); if (fp and *itr == Q) itr = next(itr); A[j] = *itr; s.erase(A[j]); if (A[j] == P) fp = false; } output(A); } } puts("-1"); }