#include <bits/stdc++.h>
using namespace std;
int pre[50005];
int n, r1, r2;
void dfs(int x) {
  int p;
  p = pre[x];
  if (p == -1)
    return;
  else
    dfs(p);
  pre[p] = x;
}
int main() {
  int i;
  cin >> n >> r1 >> r2;
  for (i = 1; i <= n; i++) {
    if (i == r1) {
      pre[i] = -1;
      continue;
    }
    cin >> pre[i];
  }
  dfs(r2);
  int p = pre[r2], q = r2, tmp;
  for (i = 1; i <= n; i++)
    if (i != r2) cout << pre[i] << ' ';
  cout << endl;
  return 0;
}
