/*** author: yuji9511 ***/ #include using namespace std; using ll = long long; using lpair = pair; const ll MOD = 1e9+7; const ll INF = 1e18; #define rep(i,m,n) for(ll i=(m);i<(n);i++) #define rrep(i,m,n) for(ll i=(m);i>=(n);i--) #define printa(x,n) for(ll i=0;i void print(H&& h, T&&... t){cout<(t)...);} int main(){ cin.tie(0); ios::sync_with_stdio(false); ll N,P,Q; cin >> N >> P >> Q; ll A[200010]; rep(i,0,N) cin >> A[i]; bool ok = false; ll p = -1, q = -1; ll pos[200010]; rep(i,0,N) pos[A[i]] = i; // ll r = next_permutation(A, A+N); // if(r == 0){ // print(-1); // return 0; // } set st; if(pos[P] < pos[Q]){ rrep(i,N-1,0){ ll cur = A[i]; if(cur == P) st.erase(Q); auto itr = st.lower_bound(cur); if(itr != st.end()){ ok = true; // print(i); ll v = *itr; st.erase(v); st.insert(A[i]); if(A[i] == P) st.erase(Q); A[i] = v; ll idx = i+1; // print(idx); while(st.size()){ auto it = st.begin(); ll val = *it; // print(val); if(val == P) st.insert(Q); A[idx] = val; idx++; st.erase(it); } break; }else{ st.insert(A[i]); if(A[i] == P){ st.erase(Q); } } } }else{ exit(1); rrep(i,N-1,0){ ll cur = A[i]; if(i > pos[Q]){ st.insert(A[i]); }else{ auto itr = st.lower_bound(A[i]); if(itr == st.end()){ if(A[i] != Q) st.insert(A[i]); }else{ // print(i); ok = true; ll v = *itr; if(A[i] != Q && v != P) st.insert(A[i]); if(v == P){ st.insert(A[i]); }else if(A[i] != Q){ st.insert(A[i]); } A[i] = v; st.erase(v); ll idx = i+1; while(st.size()){ auto itr = st.begin(); ll val = *itr; // print(val); if(val == P) st.insert(Q); A[idx] = val; idx++; st.erase(val); } } } } } if(not ok){ print(-1); }else{ printa(A, N); } }