#include <bits/stdc++.h>
using namespace std;
long n, r1, r2, p[50001];
int main() {
  cin >> n >> r1 >> r2;
  for (long i = 1; i <= n; i++)
    if (i != r1)
      cin >> p[i];
    else
      p[i] = i;
  long pre = p[r2], j = r2;
  do {
    long temp = p[pre];
    p[pre] = j;
    j = pre;
    pre = temp;
  } while (pre != j);
  if (r2 != 1) cout << p[1];
  for (long i = 2; i <= n; i++)
    if (i != r2) cout << " " << p[i];
  return 0;
}
