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