#include <bits/stdc++.h>
using namespace std;
int n, r1, r2, Cnt, Head[50005], fa[50005];
struct Edge {
  int u, v, nxt;
} edge[50005 << 1];
template <typename Drake>
void Read(Drake &x) {
  x = 0;
  char ch = getchar();
  int f = 1;
  while (!isdigit(ch)) {
    if (ch == '-') f = -f;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  x = x * f;
}
template <typename Drake>
void write(Drake x) {
  if (x >= 10) write(x / 10);
  putchar((char)(x % 10 + '0'));
}
template <typename Drake>
void writeln(Drake x) {
  write(x);
  puts("");
}
void Addedge(int u, int v) {
  ++Cnt;
  edge[Cnt].u = u;
  edge[Cnt].v = v;
  edge[Cnt].nxt = Head[u];
  Head[u] = Cnt;
}
void Dfs(int Node) {
  for (int i = Head[Node]; i; i = edge[i].nxt) {
    if (edge[i].v != fa[Node]) {
      fa[edge[i].v] = Node;
      Dfs(edge[i].v);
    }
  }
}
int main() {
  Read(n);
  Read(r1);
  Read(r2);
  Cnt = 0;
  memset(Head, 0, sizeof Head);
  for (int i = 1; i < r1; ++i) {
    int v;
    Read(v);
    Addedge(i, v);
    Addedge(v, i);
  }
  for (int i = r1 + 1; i <= n; ++i) {
    int v;
    Read(v);
    Addedge(v, i);
    Addedge(i, v);
  }
  memset(fa, 0, sizeof fa);
  fa[r2] = r2;
  Dfs(r2);
  for (int i = 1; i < r2; ++i) write(fa[i]), putchar(' ');
  for (int i = r2 + 1; i <= n; ++i) write(fa[i]), putchar(' ');
  puts("");
  return 0;
}
