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