#include <bits/stdc++.h>
using namespace std;
int a[50050];
void fun(int r2) {
  int p = a[r2];
  if (p != -1) {
    fun(p);
    a[p] = r2;
  } else
    return;
}
int main() {
  int i, j, k, x;
  int n, r1, r2;
  cin >> n >> r1 >> r2;
  r1 = r1 - 1;
  r2 = r2 - 1;
  for (i = 0; i < n; i++) {
    if (i != r1) {
      cin >> x;
      a[i] = x - 1;
    }
  }
  a[r1] = -1;
  fun(r2);
  a[r2] = -1;
  for (i = 0; i < n; i++) {
    if (i != r2) {
      cout << a[i] + 1 << " ";
    }
  }
  return 0;
}
