#include <bits/stdc++.h>
using namespace std;
vector<int> gr[50005];
int parent[50005];
void dfs(int src, int par) {
  parent[src] = par;
  for (auto nbr : gr[src]) {
    if (nbr != par) dfs(nbr, src);
  }
}
int main() {
  int n, x, y;
  cin >> n >> x >> y;
  for (int i = 1; i <= n; i++) {
    if (i == x) continue;
    int p;
    cin >> p;
    gr[i].push_back(p);
    gr[p].push_back(i);
  }
  dfs(y, 0);
  for (int i = 1; i <= n; i++) {
    if (i == y) continue;
    cout << parent[i] << " ";
  }
  return 0;
}
