#include <bits/stdc++.h>
using namespace std;
long long n, r1, r2, was[50001], res[50001];
vector<vector<int> > a;
void dfs(int s) {
  ++was[s];
  int k = (int)a[s].size();
  for (int i = 0; i < k; ++i) {
    int y = (int)a[s][i];
    if (!was[y]) {
      res[y] = s + 1;
      dfs(y);
    }
  }
}
int main() {
  cin >> n >> r1 >> r2;
  a.resize(n);
  for (int i = 0; i < n; ++i)
    if (i + 1 != r1) {
      int x;
      cin >> x;
      --x;
      a[i].push_back(x);
      a[x].push_back(i);
    }
  --r2;
  memset(was, 0, sizeof was);
  memset(res, 0, sizeof res);
  dfs(r2);
  for (int i = 0; i < n; ++i)
    if (i != r2) cout << res[i] << ' ';
  return 0;
}
