#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e4 + 5;
vector<int> G[maxn];
int n, root, nroot;
int par[maxn];
int vis[maxn];
void dfs(int u, int p) {
  vis[u] = 1;
  par[u] = p;
  for (auto v : G[u]) {
    if (vis[v] == 0) {
      dfs(v, u);
    }
  }
}
int main() {
  cin >> n >> root >> nroot;
  --root, --n, --nroot;
  int cnt = 0;
  int tmp = n;
  while (n--) {
    int u;
    cin >> u;
    --u;
    if (cnt == root) cnt += 1;
    G[cnt].push_back(u), G[u].push_back(cnt);
    cnt++;
  }
  memset(vis, 0, sizeof vis);
  dfs(nroot, -1);
  for (int i = 0; i <= tmp; i++) {
    if (par[i] == -1) continue;
    cout << par[i] + 1 << " ";
  }
}
