#include <bits/stdc++.h>
using namespace std;
long long gcd(long long x, long long y) { return (y ? gcd(y, x % y) : x); }
long long lcm(long long x, long long y) {
  return x * (y / gcd((long long)x, (long long)y));
}
int main() {
  int n, r1, r2;
  cin >> n >> r1 >> r2;
  vector<int> a(n + 1, -1);
  for (int i = 1; i <= n; i++) {
    if (i == r1) continue;
    cin >> a[i];
  }
  int u = r2;
  vector<int> ans = a;
  ans[u] = -1;
  while (u != r1) {
    int v;
    v = a[u];
    ans[v] = u;
    u = v;
  }
  for (int i = 1; i <= n; i++) {
    if (i == r2) continue;
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;
}
