#include <bits/stdc++.h>
int main() {
  int n, r1, r2, a[50001], b[50001];
  int i, u;
  scanf("%d%d%d", &n, &r1, &r2);
  a[r1 - 1] = r1;
  for (i = 0; i < r1 - 1; i++) scanf("%d", &a[i]);
  for (i = r1; i < n; i++) scanf("%d", &a[i]);
  u = r2;
  while (u != r1) {
    b[a[u - 1] - 1] = u;
    u = a[u - 1];
  }
  for (i = 0; i < r2 - 1; i++)
    (b[i] != 0) ? (printf("%d ", b[i])) : (printf("%d ", a[i]));
  for (i = r2; i < n; i++)
    (b[i] != 0) ? (printf("%d ", b[i])) : (printf("%d ", a[i]));
  return 0;
}
