#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7, siz = 1e6 + 5;
vector<long long> g[siz];
long long t, n, m, k, r1, r2, ans[siz];
void go(long long u, long long p) {
  ans[u] = p;
  for (auto v : g[u])
    if (v != p) go(v, u);
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> r1 >> r2;
  for (long long i = 1; i <= n; i++) {
    if (i == r1) continue;
    long long p;
    cin >> p;
    g[p].push_back(i);
    g[i].push_back(p);
  }
  go(r2, 0);
  for (long long i = 1; i <= n; i++)
    if (i != r2) cout << ans[i] << " ";
}
