#include <bits/stdc++.h>
using namespace std;
struct debugger {
  static void call(string::iterator it, string::iterator ed) {}
  template <typename T, typename... aT>
  static void call(string::iterator it, string::iterator ed, T a, aT... rest) {
    string b;
    for (; *it != ','; ++it)
      if (*it != ' ') b += *it;
    cout << b << "=" << a << " ";
    call(++it, ed, rest...);
  }
};
const int MX = 5e4 + 10;
vector<int> G[MX];
int n, r1, r2;
void dfs() {
  stack<int> stk;
  stk.push(r2);
  bool V[n + 10];
  memset(V, 0, sizeof(V));
  V[r2] = 1;
  int A[n + 10];
  while (!stk.empty()) {
    int u = stk.top();
    stk.pop();
    for (int i = 0; i < (int)(G[u].size()); ++i) {
      int v = G[u][i];
      if (V[v] == 0) {
        A[v] = u;
        stk.push(v);
        V[v] = 1;
      }
    }
  }
  for (int i = (int)(1); i < (int)(n + 1); ++i) {
    if (i == r2) continue;
    printf("%d ", A[i]);
  }
  puts("");
}
int main() {
  scanf("%d %d %d", &n, &r1, &r2);
  for (int i = (int)(1); i < (int)(n + 1); ++i) {
    if (i == r1) continue;
    int a;
    scanf("%d", &a);
    G[i].push_back(a);
    G[a].push_back(i);
  }
  dfs();
}
