#include <bits/stdc++.h>
using namespace std;
int a[1000000];
int b[1000000];
int main(int argc, char* const argv[]) {
  int n, r1, r2;
  cin >> n >> r1 >> r2;
  int j = 0;
  r1--;
  r2--;
  for (int i = 0; i + 1 < n; i++, j++) {
    if (i == r1) {
      j++;
    }
    cin >> a[j];
    a[j]--;
  }
  a[r1] = -1;
  memcpy(b, a, sizeof(a));
  if (r1 != r2) {
    int k = r2;
    b[r2] = -1;
    while (k != r1) {
      int l = a[k];
      b[l] = k;
      k = l;
    }
  }
  int ok = false;
  for (int i = 0; i < n; i++) {
    if (b[i] != -1) {
      if (ok) cout << " ";
      cout << b[i] + 1;
      ok = 1;
    }
  }
  return 0;
}
