#include <bits/stdc++.h>
using namespace std;
int n, r1, r2, x, p[100001];
vector<int> v[100001];
void dfs(int x, int P) {
  for (int i = 0; i < v[x].size(); i++) {
    int V = v[x][i];
    if (V == P) continue;
    p[V] = x;
    dfs(V, x);
  }
}
int main() {
  cin >> n >> r1 >> r2;
  for (int i = 1; i <= n; i++)
    if (i != r1) cin >> x, v[x].push_back(i), v[i].push_back(x);
  dfs(r2, 0);
  for (int i = 1; i <= n; i++)
    if (i != r2) cout << p[i] << " ";
  cout << endl;
  return 0;
}
