#include <bits/stdc++.h>
using namespace std;
vector<int> v[100010];
int n, r1, r2;
int par[100010];
void dfs(int node, int p) {
  par[node] = p;
  int sz = v[node].size();
  for (int i = 0; i < sz; i++) {
    int nx = v[node][i];
    if (nx != p) dfs(nx, node);
  }
}
int main() {
  cin >> n >> r1 >> r2;
  for (int i = 1; i <= n; i++) {
    int x;
    if (i == r1) continue;
    cin >> x;
    v[x].push_back(i);
    v[i].push_back(x);
  }
  dfs(r2, r2);
  for (int i = 1; i <= n; i++) {
    if (i == r2) continue;
    cout << par[i] << " ";
  }
  cout << '\n';
}
