#include <bits/stdc++.h>
using namespace std;
int ara[50005];
vector<int> v[50005];
void dfs(int node, int parent) {
  ara[node] = parent;
  for (int i = 0; i < v[node].size(); i++) {
    if (v[node][i] == parent)
      continue;
    else
      dfs(v[node][i], node);
  }
}
int main() {
  int n, r1, r2, x;
  cin >> n >> r1 >> r2;
  for (int i = 1; i <= n; i++) {
    if (i == r1) continue;
    cin >> x;
    v[i].push_back(x);
    v[x].push_back(i);
  }
  dfs(r2, -1);
  int f = 0;
  for (int i = 1; i <= n; i++) {
    if (i == r2) continue;
    if (f) cout << " ";
    f = 1;
    cout << ara[i];
  }
  return 0;
}
