#include <bits/stdc++.h>
using namespace std;
int n, r1, r2;
vector<vector<int> > g1;
vector<int> g2;
vector<bool> used;
void dfs(int v, int p) {
  used[v] = true;
  if (p != -1) {
    g2[v] = p;
  }
  for (vector<int>::iterator i = g1[v].begin(); i != g1[v].end(); ++i)
    if (!used[*i]) dfs(*i, v);
}
int main() {
  cin >> n >> r1 >> r2;
  g1.resize(n + 1);
  g2.resize(n + 1);
  used.resize(n + 1);
  used[0] = true;
  int a, b;
  for (int i = 1; i <= n; i++) {
    if (i == r1) continue;
    cin >> a;
    g1[i].push_back(a);
    g1[a].push_back(i);
  }
  dfs(r2, -1);
  for (int i = 1; i <= n; i++) {
    if (i != r2) cout << g2[i] << " ";
  }
  cout << endl;
  return 0;
}
