#include using namespace std; //#include //using multiInt = boost::multiprecision::cpp_int; using ll = long long int; using ld = long double; using pii = pair; using pll = pair; template using smaller_queue = priority_queue, greater>; const int MOD_TYPE = 1; const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353); const int INF = (int)1e9; const ll LINF = (ll)4e18; const ld PI = acos(-1.0); const ld EPS = 1e-11; #define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i) #define rep(i, n) REP(i, 0, n) #define MP make_pair #define MT make_tuple #define YES(n) cout << ((n) ? "YES" : "NO") << endl #define Yes(n) cout << ((n) ? "Yes" : "No") << endl #define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl #define possible(n) cout << ((n) ? "possible" : "impossible") << endl #define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl #define all(v) v.begin(), v.end() #define NP(v) next_permutation(all(v)) #define dbg(x) cerr << #x << ":" << x << endl; vector Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0}; vector Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0}; int main() { cin.tie(0); ios::sync_with_stdio(false); cout << setprecision(30) << setiosflags(ios::fixed); int n, p, q; cin >> n >> p >> q; int a[100010]; rep(i, n) cin >> a[i]; //先頭x文字がAと一致 auto simulate = [&](int x) { if (x == -1) return true; bool used[100010] = {}; rep(i, x) { if (a[i] == q && !used[p]) return false; used[a[i]] = true; } if (used[p]) { REP(i, x, n) { if (a[i] > a[x]) return true; } return false; } else { REP(i, x, n) { if (a[i] > a[x] && a[i] != q) return true; } return false; } }; int lo = -2, hi = n; while (hi - lo > 1) { int mi = (lo + hi) / 2; if (simulate(mi)) lo = mi; else hi = mi; } int match = lo; dbg(match); if (match == -1) { cout << -1 << endl; return 0; } bool used[100010] = {}; int b[100010]; rep(i, match) { used[a[i]] = true; b[i] = a[i]; } if (used[p]) { for (int i = a[match] + 1; i <= n; i++) { if (!used[i]) { b[match] = i; used[i] = true; break; } } int bi = match + 1; for (int i = 1; i <= n && bi < n; i++) { if (!used[i]) { b[bi] = i; bi++; } } assert(bi == n); } else if (p < q) { for (int i = a[match] + 1; i <= n; i++) { if (!used[i] && i != q) { b[match] = i; used[i] = true; break; } } int bi = match + 1; for (int i = 1; i <= n && bi < n; i++) { if (!used[i]) { b[bi] = i; bi++; } } assert(bi == n); } else { int bi = match; for (int i = a[match] + 1; i <= n; i++) { if (!used[i] && i != q) { b[bi] = i; used[i] = true; bi++; if (i == p) { b[bi] = q; used[q] = true; bi++; } break; } } for (int i = 1; i <= n; i++) { if (!used[i] && i != q) { b[bi] = i; bi++; if (i == p) { b[bi] = q; bi++; } } } assert(bi == n); } rep(i, n) cout << b[i] << (i == n - 1 ? "\n" : " "); return 0; }