#include <bits/stdc++.h>
using namespace std;
const int QUA = (int)5 * 1e4 + 2;
vector<int> cities[QUA];
bool was[QUA];
int ans[QUA];
void go(int s) {
  was[s] = true;
  for (int i = 0; i < cities[s].size(); ++i) {
    int wh = cities[s][i];
    if (!was[wh]) {
      ans[wh] = s;
      go(wh);
    }
  }
}
int main() {
  int n, r1, r2;
  scanf("%d %d %d", &n, &r1, &r2);
  for (int i = 0; i < n; ++i) {
    was[i] = false;
    cities[i].clear();
  }
  r1--, r2--;
  for (int i = 0; i < n - 1; ++i) {
    int from;
    scanf("%d", &from);
    from--;
    int to = i;
    if (i >= r1) {
      to++;
    }
    cities[from].push_back(to);
    cities[to].push_back(from);
  }
  go(r2);
  for (int i = 0; i < n; ++i) {
    if (i != r2) {
      printf("%d ", ans[i] + 1);
    }
  }
  return 0;
}
