#include <bits/stdc++.h>
using namespace std;
struct node {
  int p;
  int s;
};
int n, r1, r2;
node test[50001];
int main() {
  while (cin >> n >> r1 >> r2) {
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
      int tp;
      if (i == r1) continue;
      scanf("%d", &tp);
      test[i].p = tp;
      if (i != r1) test[tp].s = i;
    }
    int tc = r2;
    int ts = test[r2].p;
    int flag = 1;
    while (flag) {
      if (ts == r1) flag = 0;
      int tmp = test[ts].p;
      test[ts].p = tc;
      tc = ts;
      ts = tmp;
    }
    for (int i = 1; i <= n; i++) {
      if (i == r2) continue;
      cout << test[i].p << " ";
    }
    cout << endl;
  }
  return 0;
}
