#include <bits/stdc++.h>
using namespace std;
int n, r1, r2;
const int N = 1e5 + 5;
int ans[N];
vector<vector<int>> v(N);
int vis[N];
void solve(int node = r2) {
  if (vis[node]) return;
  vis[node] = 1;
  for (int i = 0; i < v[node].size(); i++) {
    if (!ans[v[node][i]]) ans[v[node][i]] = node;
  }
  for (int i = 0; i < v[node].size(); i++) solve(v[node][i]);
}
int main() {
  cin >> n >> r1 >> r2;
  int a[n - 1];
  for (int i = 0; i < n - 1; i++) cin >> a[i];
  bool f = 0;
  for (int i = 0; i < n; i++) {
    if (i + 1 != r1) {
      v[a[i - f]].push_back(i + 1);
      v[i + 1].push_back(a[i - f]);
    } else
      f = 1;
  }
  solve();
  for (int i = 1; i <= n; i++) {
    if (i == r2) continue;
    cout << ans[i] << " ";
  }
}
