#include using namespace std; #define DEBUG(x) cerr<<#x<<": "< #define vl vector #define vii vector< vector > #define vll vector< vector > #define vs vector #define pii pair #define pis pair #define psi pair #define pll pair template pair operator+(const pair &s, const pair &t) { return pair(s.first + t.first, s.second + t.second); } template pair operator-(const pair &s, const pair &t) { return pair(s.first - t.first, s.second - t.second); } template ostream& operator<<(ostream& os, pair p) { os << "(" << p.first << ", " << p.second << ")"; return os; } #define X first #define Y second #define rep(i,n) for(int i=0;i<(int)(n);i++) #define rep1(i,n) for(int i=1;i<=(int)(n);i++) #define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--) #define rrep1(i,n) for(int i=(int)(n);i>0;i--) #define REP(i,a,b) for(int i=a;i bool chmax(T &a, const T &b) { if (a bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; } #define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end()); const ll inf = 1000000001; const ll INF = (ll)1e18 + 1; const long double pi = 3.1415926535897932384626433832795028841971L; #define Sp(p) cout< st; rep (i, n) { if (i != q) st.insert(i); } bool big = false; rep (i, n) { if (not big) { auto itr = st.end(); if (itr == st.begin()) return false; itr--; int x = *itr; if (x > a[i]) { big = true; st.erase(x); } else if (x == a[i]) { st.erase(x); } else { return false; } if (x == p) st.insert(q); } else { auto itr = st.end(); if (itr == st.begin()) return false; itr--; int x = *itr; st.erase(x); if (x == p) st.insert(q); } } return true; } vi check(int mid) { set st; rep (i, n) { if (i != q) st.insert(i); } vi b(n); rep (i, mid) { if (st.count(a[i]) == 0) { return vi(1, -1); } st.erase(a[i]); b[i] = a[i]; if (a[i] == p) st.insert(q); } for (int i = mid; i < n; i++) { if (i == mid) { auto itr = st.lower_bound(a[i] + 1); if (itr == st.end()) { return vi(1, -1); } int x = *itr; st.erase(itr); b[i] = x; if (x == p) st.insert(q); } else { auto itr = st.begin(); int x = *itr; st.erase(itr); b[i] = x; if (x == p) st.insert(q); } } return b; } signed main() { fio(); cin >> n >> p >> q; p--; q--; a.resize(n); rep (i, n) { cin >> a[i]; a[i]--; } if (not check1()) { cout << -1 << endl; return 0; } int ok = 0, ng = n; while (ok + 1 < ng) { int mid = (ok + ng) / 2; vi res = check(mid); if (res[0] == -1) ng = mid; else ok = mid; } vi res = check(ok); rep (i, n) { cout << res[i] + 1 << " "; } cout << endl; }