#include <bits/stdc++.h>
using namespace std;
int n, cap, cap2, arr[500000];
int main() {
  int i, a;
  cin >> n >> cap >> cap2;
  for (i = 1; i <= n; i++) {
    if (i == cap) continue;
    cin >> a;
    arr[i] = a;
  }
  int node = arr[cap2], bef = cap2;
  while (node) {
    int temp = arr[node];
    arr[node] = bef;
    bef = node;
    node = temp;
  }
  for (i = 1; i <= n; i++)
    if (i != cap2) cout << arr[i] << " ";
  return 0;
}
