#include <bits/stdc++.h>
using namespace std;
int p[100000];
int main() {
  int n, r1, r2;
  cin >> n >> r1 >> r2;
  for (int i = 1; i < r1; i++) cin >> p[i];
  for (int i = r1 + 1; i <= n; i++) cin >> p[i];
  int WHERE = r2, WHAT = 0, bufWHERE, bufWHAT;
  while (WHERE) {
    bufWHERE = WHERE;
    bufWHAT = WHAT;
    WHERE = p[WHERE];
    WHAT = bufWHERE;
    p[bufWHERE] = bufWHAT;
  }
  for (int i = 1; i < r2; i++) cout << p[i] << " ";
  for (int i = r2 + 1; i <= n; i++) cout << p[i] << " ";
  return 0;
}
