#include <bits/stdc++.h>
using namespace std;
vector<int> edge[55555];
int ans[55555];
void dfs(int root, int pre) {
  for (int i = 0; i < edge[root].size(); i++) {
    int v = edge[root][i];
    if (v == pre) continue;
    ans[v] = root;
    dfs(v, root);
  }
}
int main() {
  int n, r1, r2;
  scanf("%d%d%d", &n, &r1, &r2);
  for (int i = 1; i <= n; i++) {
    edge[i].clear();
  }
  for (int i = 1; i <= n; i++) {
    if (i == r1) continue;
    int f;
    scanf("%d", &f);
    edge[f].push_back(i);
    edge[i].push_back(f);
  }
  dfs(r2, -1);
  bool f = true;
  for (int i = 1; i <= n; i++) {
    if (i == r2) continue;
    if (f)
      f = false;
    else
      printf(" ");
    printf("%d", ans[i]);
  }
  puts("");
}
