#include <bits/stdc++.h>
using namespace std;
vector<int> b;
int a[60000], c[60000];
int main() {
  int n, r1, r2, newr1, j, i, k, p = -1;
  cin >> n >> r1 >> r2;
  j = 0;
  a[r1] = 0;
  for (i = 1; i <= n - 1; i++) {
    cin >> k;
    j++;
    if (i == r1) j++;
    a[j] = k;
    c[j] = k;
    if (k == r1) b.push_back(j);
  }
  p = r2;
  while (a[p] != r1) {
    c[a[p]] = p;
    p = a[p];
  }
  c[r1] = p;
  for (i = 1; i <= n; i++)
    if (i != r2) cout << c[i] << " ";
  return 0;
}
