#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, r1, r2, parent;
  int towntree[50000];
  cin >> n >> r1 >> r2;
  for (int i = 0; i < n; ++i) {
    if (i == (r1 - 1)) {
      towntree[i] = -1;
      continue;
    }
    cin >> parent;
    towntree[i] = parent - 1;
  }
  bool containsYet = true;
  int futureParent = r2 - 1;
  parent = towntree[futureParent];
  towntree[futureParent] = -1;
  while (containsYet) {
    int pp = towntree[parent];
    if (pp == -1) containsYet = false;
    towntree[parent] = futureParent;
    futureParent = parent;
    parent = pp;
  }
  for (int i = 0; i < n; ++i) {
    if (towntree[i] == -1) continue;
    cout << towntree[i] + 1 << " ";
  }
  return 0;
}
