#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > g;
int *from;
void dfs(int v, int fr) {
  from[v] = fr;
  for (int i = 0; i < g[v].size(); i++) {
    if (g[v][i] == fr) continue;
    dfs(g[v][i], v);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, r1, r2;
  cin >> n >> r1 >> r2;
  r1--;
  r2--;
  g.resize(n);
  from = new int[n];
  int a;
  for (int i = 0; i < n; i++) {
    if (i == r1) continue;
    cin >> a;
    a--;
    g[i].push_back(a);
    g[a].push_back(i);
  }
  dfs(r2, -1);
  for (int i = 0; i < n; i++) {
    if (i == r2) continue;
    cout << from[i] + 1 << " ";
  }
  return 0;
}
