#include <bits/stdc++.h>
using namespace std;
int vis[50005];
vector<long long> v[50005];
long long ans[50005];
void dfs(long long i) {
  vis[i] = 1;
  long long j;
  for (j = 0; j < v[i].size(); j++) {
    if (!vis[v[i][j]]) {
      ans[v[i][j]] = i;
      dfs(v[i][j]);
    }
  }
}
int main() {
  long long n, i, r1, r2;
  cin >> n >> r1 >> r2;
  for (i = 1; i <= n; i++) {
    if (i == r1)
      continue;
    else {
      long long x;
      cin >> x;
      v[i].push_back(x);
      v[x].push_back(i);
    }
  }
  dfs(r2);
  for (i = 1; i <= n; i++) {
    if (i != r2) cout << ans[i] << " ";
  }
  return 0;
}
