#include <bits/stdc++.h>
using namespace std;
int n, a, b, chu[100000];
vector<int> cun[100000];
inline void dfs(int xu, int fa) {
  chu[xu] = fa;
  for (int i = 0; i < cun[xu].size(); ++i)
    if (cun[xu][i] != fa) dfs(cun[xu][i], xu);
}
inline int read() {
  int date = 0, w = 1;
  char c = 0;
  while (!isdigit(c)) {
    if (c == '-') w = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    date = date * 10 + c - '0';
    c = getchar();
  }
  return date * w;
}
int main() {
  n = read();
  a = read();
  b = read();
  for (int i = 1; i <= n; i++) {
    if (i == a) continue;
    int c = read();
    cun[i].push_back(c);
    cun[c].push_back(i);
  }
  dfs(b, 0);
  for (int i = 1; i <= n; i++) {
    if (i == b) continue;
    printf("%d ", chu[i]);
  }
  return 0;
}
