#include <bits/stdc++.h>
const int maxn = 5e4 + 10;
int n, r1, r2;
int head[maxn], cnt, f[maxn];
struct edge {
  int to, next;
} edges[maxn << 1];
void addedge(int u, int v) {
  edges[cnt].to = v;
  edges[cnt].next = head[u];
  head[u] = cnt++;
}
void dfs(int u, int pa) {
  for (int k = head[u]; k != -1; k = edges[k].next)
    if (edges[k].to != pa) {
      f[edges[k].to] = u;
      dfs(edges[k].to, u);
    }
}
int main() {
  while (~scanf("%d%d%d", &n, &r1, &r2)) {
    memset(head, -1, sizeof(head));
    cnt = 0;
    for (int u = 1; u <= n; u++)
      if (u != r1) {
        int v;
        scanf("%d", &v);
        addedge(u, v);
        addedge(v, u);
      }
    dfs(r2, -1);
    int flag = 0;
    for (int i = 1; i <= n; i++)
      if (i != r2) {
        if (flag)
          putchar(' ');
        else
          flag = 1;
        printf("%d", f[i]);
      }
    putchar('\n');
  }
  return 0;
}
