#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define llint long long #define inf 1e18 #define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++) #define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++) #define chmin(x, y) (x) = min((x), (y)) #define chmax(x, y) (x) = max((x), (y)) #define mod 1000000007 using namespace std; typedef pair P; llint n, p, q; llint a[200005], b[200005]; bool ok[200005]; set S; bool dfs(llint i) { if(i == n) return false; bool ret = false; if(S.count(p) == 0){ bool flag = false; for(int j = i; j < n; j++){ if(a[j] < a[j+1]) flag = true; } ret |= flag; if(flag){ llint pos; for(int j = i; j < n; j++) { if(a[j] < a[j+1]) pos = j; } for(int j = i; j <= pos; j++) ok[j] = true; } } else{ if(a[i] != q){ S.erase(a[i]); ret |= dfs(i+1); S.insert(a[i]); } } //cout << i << " " << ret << endl; auto it = S.upper_bound(a[i]); if(it == S.end()) return ret; if(!(*it == q && S.count(p))) return ok[i] = true; it++; if(it == S.end()) return ret; if(!(*it == q && S.count(p))) return ok[i] = true; return ok[i] = ret; } void make(llint l) { //cout << l << endl; for(int i = l; i <= n; i++){ //for(auto x:S) cout << x << " "; cout << endl; auto it = S.begin(); if(!(*it == q && S.count(p))){ b[i] = *it; S.erase(*it); continue; } it++; if(!(*it == q && S.count(p))){ b[i] = *it; S.erase(*it); continue; } } } int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> p >> q; for(int i = 1; i <= n; i++) cin >> a[i]; for(int i = 1; i <= n; i++) S.insert(i); dfs(1); ///for(int i = 1; i <= n; i++) cout << ok[i] << " "; cout << endl; if(!ok[1]){ cout << -1 << endl; return 0; } for(int i = 1; i <= n; i++){ if(ok[i+1]){ b[i] = a[i]; S.erase(a[i]); continue; } auto it = S.upper_bound(a[i]); if(!(it == S.end() || (*it == q && S.count(p)))){ b[i] = *it; S.erase(*it); make(i+1); break; } it++; if(!(it == S.end() || (*it == q && S.count(p)))){ b[i] = *it; S.erase(*it); make(i+1); break; } } for(int i = 1; i <= n; i++) cout << b[i] << " "; cout << endl; return 0; }