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