#include <bits/stdc++.h>
using namespace std;
vector<int> G[100000];
int p[100000];
int vist[100000] = {};
void dfs(int v) {
  vist[v] = 1;
  for (int i = 0; i < G[v].size(); i++) {
    int u = G[v][i];
    if (!vist[u]) {
      p[u] = v;
      dfs(u);
    }
  }
}
int main() {
  int n, z, r1, r2;
  int v;
  scanf("%d%d%d", &n, &r1, &r2);
  for (int i = 1; i <= n; i++) {
    if (i != r1) {
      scanf("%d", &v);
      G[i].push_back(v);
      G[v].push_back(i);
    }
  }
  dfs(r2);
  bool f = false;
  ;
  for (int i = 1; i <= n; i++) {
    if (i != r2) {
      if (f)
        printf(" ");
      else
        f = true;
      printf("%d", p[i]);
    }
  }
  printf("\n");
  return 0;
}
