#include <bits/stdc++.h>
using namespace std;
bool vis[100001];
int ret[100001];
vector<vector<int> > g;
void dfs(int curr) {
  for (int i = 0; i < g[curr].size(); ++i) {
    if (!vis[g[curr][i]]) {
      vis[g[curr][i]] = 1;
      int to = g[curr][i];
      ret[g[curr][i]] = curr + 1;
      dfs(g[curr][i]);
    }
  }
}
int main() {
  int n, r1, r2;
  scanf("%d%d%d", &n, &r1, &r2);
  g.resize(n);
  --r1;
  --r2;
  int cur = 0, x;
  for (int i = 0; i < n - 1; ++i) {
    if (cur == r1) cur++;
    scanf("%d", &x);
    x--;
    g[x].push_back(cur);
    g[cur].push_back(x);
    cur++;
  }
  vis[r2] = 1;
  dfs(r2);
  bool fr = 1;
  for (int i = 0; i < n; ++i) {
    if (i != r2) {
      if (!fr) printf(" ");
      printf("%d", ret[i]), fr = 0;
    }
  }
  return 0;
}
