#include <bits/stdc++.h>
using namespace std;
bool band[100000] = {false};
vector<int> arr[100000];
int sol[100000] = {0};
void bfs(int v) {
  queue<int> cola;
  cola.push(v);
  while (!cola.empty()) {
    int v = cola.front();
    cola.pop();
    if (band[v] == true) continue;
    band[v] = true;
    for (int i = 0; i < arr[v].size(); i++) {
      int num = arr[v][i];
      if (band[num] == true) continue;
      cola.push(num);
      sol[num] = v;
    }
  }
  return;
}
int main() {
  int num, n, r1, r2;
  scanf("%d %d %d", &n, &r1, &r2);
  for (int i = 1; i < n + 1; i++) {
    if (i == r1) continue;
    scanf("%d", &num);
    arr[i].push_back(num);
    arr[num].push_back(i);
  }
  bfs(r2);
  bool band = false;
  for (int i = 1; i < n + 1; i++) {
    if (i == r2) continue;
    if (band == false)
      printf("%d", sol[i]), band = true;
    else
      printf(" %d", sol[i]);
  }
  printf("\n");
  return 0;
}
