#include <bits/stdc++.h>
using namespace std;
struct node {
  vector<int> adj;
} graf[5 * 10010];
bool mark[5 * 10010];
int last[5 * 10010];
void DFS(int u, int lst) {
  last[u] = lst;
  mark[u] = true;
  for (int i = 0; i < graf[u].adj.size(); i++)
    if (!mark[graf[u].adj[i]]) DFS(graf[u].adj[i], u);
}
int main() {
  int n, r1, r2;
  scanf("%d%d%d", &n, &r1, &r2);
  for (int i = 1; i <= n; i++) {
    if (i == r1) continue;
    int tmp;
    scanf("%d", &tmp);
    graf[i].adj.push_back(tmp);
    graf[tmp].adj.push_back(i);
  }
  DFS(r2, 0);
  for (int i = 1; i <= n; i++) {
    if (i == r2) continue;
    printf("%d ", last[i]);
  }
  printf("\n");
  return 0;
}
