#include <bits/stdc++.h>
using namespace std;
inline int iin() {
  int x;
  scanf("%d", &x);
  return x;
}
inline long long int lin() {
  long long int x;
  scanf("%lld", &x);
  return x;
}
inline long long int Lin() {
  long long int x;
  scanf("%I64d", &x);
  return x;
}
inline int iout(int x) { printf("%d", x); }
inline long long int lout(long long int x) { printf("%lld", x); }
inline long long int Lout(long long int x) { printf("%I64d", x); }
const int maxn4 = 1e4 + 85, maxn5 = 1e5 + 69, maxn6 = 1e6 + 85,
          maxn7 = 1e7 + 69, maxn8 = 1e8 + 85, maxn9 = 1e9 + 69, modi1 = 1e7 + 7,
          modi2 = 1e9 + 7;
const long long int mod1 = 1e7 + 7, mod2 = 1e9 + 7;
int mn = INT_MAX, mx = INT_MIN;
int a[maxn6];
int main() {
  int n, r1, r2;
  cin >> n >> r1 >> r2;
  for (int i = 1; i <= n; i++)
    if (i != r1)
      cin >> a[i];
    else
      a[i] = 0;
  int v = r2, x = a[r2];
  while (x != 0) {
    int y = a[x];
    a[x] = v;
    v = x;
    x = y;
  }
  for (int i = 1; i <= n; i++)
    if (i != r2) cout << a[i] << ' ';
}
