#include <bits/stdc++.h>
using namespace std;
vector<long long int> arr[300000];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int t;
  t = 1;
  while (t--) {
    long long int n, r1, r2;
    cin >> n >> r1 >> r2;
    long long int cnt = 1;
    for (long long int i = 0; i < n - 1; i++) {
      long long int x;
      cin >> x;
      if (cnt == r1) cnt++;
      arr[cnt].push_back(x);
      arr[x].push_back(cnt);
      cnt++;
    }
    bool vis[300010] = {0};
    queue<long long int> crr;
    crr.push(r2);
    vis[r2] = 1;
    long long int dp[300000] = {0};
    dp[r2] = 1;
    while (!crr.empty()) {
      long long int r = crr.front();
      crr.pop();
      vis[r] = 1;
      for (auto i : arr[r])
        if (vis[i] == 0) {
          vis[i] = 1;
          crr.push(i);
          dp[i] = r;
        }
    }
    for (long long int i = 1; i <= n; i++) {
      if (i != r2) {
        cout << dp[i] << " ";
      }
    }
  }
}
