#include <bits/stdc++.h>
using namespace std;
long long int n, m, k, g, mx, mn, res, c, x, y, z, w, p, q, r, l, s, t;
vector<long long int> graph[50005];
long long int vis[50005], ans[50005];
void dfs(long long int k, long long int des) {
  for (long long int i = 0; i < graph[k].size(); i++) {
    x = graph[k][i];
    if (x == des) continue;
    ans[x] = k;
    dfs(x, k);
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> m >> k;
  for (long long int i = 1; i < n + 1; i++) {
    if (i == m) continue;
    cin >> x;
    graph[i].push_back(x);
    graph[x].push_back(i);
  }
  dfs(k, -1);
  for (long long int i = 1; i <= n; i++)
    if (i != k) cout << ans[i] << " ";
  return 0;
}
