#include <bits/stdc++.h>
using namespace std;
const int max_n = 100 * 100 * 5 + 10;
vector<int> adj[max_n];
bool seen[max_n];
int P[max_n], r1, r2, n;
void dfs(int v) {
  seen[v] = 1;
  for (auto i : adj[v])
    if (!seen[i]) {
      P[i] = v;
      dfs(i);
    }
}
int main() {
  ios_base ::sync_with_stdio(false), cout.tie(0), cin.tie(0);
  cin >> n >> r1 >> r2;
  for (int i = 1; i <= n; i++) {
    if (i - r1) {
      int a;
      cin >> a;
      adj[a].push_back(i);
      adj[i].push_back(a);
    }
  }
  dfs(r2);
  for (int i = 1; i <= n; i++)
    if (i - r2) cout << P[i] << ' ';
  return 0;
}
