#include <bits/stdc++.h>
using namespace std;
int pre[100050];
bool vis[100050];
vector<int> con[100050];
void dfs(int u) {
  vis[u] = 1;
  for (int j = 0; j < con[u].size(); j++) {
    int v = con[u][j];
    if (!vis[v]) {
      pre[v] = u;
      dfs(v);
    }
  }
}
int main() {
  int n, r1, r2;
  cin >> n >> r1 >> r2;
  for (int i = 1; i <= n; i++)
    if (i != r1) {
      int u;
      cin >> u;
      con[i].push_back(u);
      con[u].push_back(i);
    }
  dfs(r2);
  for (int i = 1; i <= n; i++)
    if (i != r2) cout << pre[i] << " ";
  cout << endl;
}
