#include <bits/stdc++.h>
using namespace std;
void sober() {
  long long int n, x = 0, a = 0, b = 0, y = 0, sum = 0, k = 0, m = 0, c = 0,
                   d = 0;
  cin >> n >> a >> b;
  vector<long long int> v(n + 1, -1);
  for (int i = 0; i < n; i++) {
    if (i + 1 != a) {
      cin >> v[i + 1];
    }
  }
  std::vector<long long int> ans(n + 1, 0);
  ans[a] = b;
  ans[b] = -1;
  long long int cur = b;
  while (v[cur] != -1) {
    ans[v[cur]] = cur;
    cur = v[cur];
  }
  for (long long int i = 1; i < n + 1; i++) {
    if (i == b) continue;
    if (ans[i] == 0) ans[i] = v[i];
    cout << ans[i] << " ";
  }
  cout << "\n";
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t = 1;
  while (t--) {
    sober();
  }
}
