#include <bits/stdc++.h>
using namespace std;
vector<long long> g[50003];
long long ans[50003];
void dfs(long long i, long long p) {
  if (ans[i] == -1) ans[i] = p;
  for (auto j : g[i])
    if (j != p) dfs(j, i);
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  fill(ans, ans + 50003, -1);
  long long n, r1, r2;
  cin >> n >> r1 >> r2;
  long long i, x;
  for (i = 1; i <= n; ++i) {
    if (i == r1) continue;
    cin >> x;
    g[i].push_back(x);
    g[x].push_back(i);
  }
  dfs(r2, r2);
  for (i = 1; i <= n; ++i)
    if (i != r2) cout << ans[i] << " ";
  return 0;
}
