#include <bits/stdc++.h>
using namespace std;
vector<int> adj[50001];
deque<int> q;
int p[50001] = {0};
int color[50001] = {0};
void dfs(int u) {
  color[u] = 1;
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i];
    if (color[v] == 0) p[v] = u, dfs(v);
  }
  q.push_front(u);
}
int main() {
  int n, r1, r2;
  cin >> n >> r1 >> r2;
  int city;
  for (int i = 1; i <= n; i++)
    if (i != r1) {
      cin >> city;
      adj[i].push_back(city), adj[city].push_back(i);
    }
  dfs(r2);
  for (int i = 1; i < n; i++)
    if (i != r2) cout << p[i] << ' ';
  if (r2 != n) cout << p[n];
  cout << endl;
}
