#include <bits/stdc++.h>
using namespace std;
void affiche(int t[], int n) {
  for (int i = 0; i < n; i++) cout << t[i] << " ";
  cout << '\n';
}
void afficheV(vector<int> t) {
  for (int i = 0; i < t.size(); i++) cout << t[i] << " ";
}
vector<vector<int> > adj(50005);
vector<bool> visited(50005, false);
int ans[50005];
int dp[50005];
int r1, r2;
void DFS(int node) {
  visited[node] = true;
  for (int i = 0; i < adj[node].size(); i++) {
    int child = adj[node][i];
    if (!visited[child]) {
      ans[child] = node;
      DFS(child);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  int n;
  cin >> n >> r1 >> r2;
  memset(dp, -1, sizeof dp);
  for (int i = 1; i < n + 1; i++) {
    if (i == r1) continue;
    int x;
    cin >> x;
    adj[x].push_back(i);
    adj[i].push_back(x);
  }
  DFS(r2);
  for (int i = 1; i < n + 1; i++) {
    if (i == r2) continue;
    cout << ans[i] << " ";
  }
}
