#include <bits/stdc++.h>
using namespace std;
vector<vector<long long>> g;
vector<bool> used;
vector<long long> b;
void dfs(long long v, long long pref = -1) {
  b[v] = pref;
  used[v] = true;
  for (long long i : g[v]) {
    if (!used[i]) {
      dfs(i, v);
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n, r1, r2;
  cin >> n >> r1 >> r2;
  g.resize(n + 1);
  used.assign(n + 1, false);
  b.resize(n + 1);
  for (long long i = 1; i < n; i++) {
    long long pos;
    cin >> pos;
    g[pos].push_back(i + (i >= r1));
    g[i + (i >= r1)].push_back(pos);
  }
  dfs(r2);
  for (long long i = 1; i <= n; i++) {
    if (b[i] == -1) {
      continue;
    }
    cout << b[i] << " ";
  }
}
