#include <bits/stdc++.h>
using namespace std;
int pai[50050];
vector<int> adj[50050];
void dfs(int u, int p = -1) {
  pai[u] = p;
  for (int v : adj[u]) {
    if (v == p) continue;
    dfs(v, u);
  }
}
int main() {
  int n, r1, r2, a;
  cin >> n >> r1 >> r2;
  for (int i = int(1); i < int(n + 1); ++i) {
    if (i == r1) continue;
    cin >> a;
    adj[a].push_back(i);
    adj[i].push_back(a);
  }
  dfs(r2);
  for (int i = int(1); i < int(n + 1); ++i) {
    if (i == r2) continue;
    cout << pai[i] << " ";
  }
  cout << endl;
  return 0;
}
