#include <bits/stdc++.h>
using namespace std;
int a[50010], hash[50010];
int main() {
  int i, j, n, r1, r2, now, last, cun;
  scanf("%d %d %d", &n, &r1, &r2);
  for (i = 1; i <= n; i++) {
    if (i == r1)
      continue;
    else
      scanf("%d", &a[i]);
  }
  now = a[r2];
  cun = r2;
  while (1) {
    last = a[now];
    a[now] = cun;
    if (now == r1) break;
    cun = now;
    now = last;
  }
  for (i = 1; i <= n; i++) {
    if (i != r2) printf("%d ", a[i]);
  }
  return 0;
}
