#include <bits/stdc++.h>
using namespace std;
int n, r1, r2, tt, s, par;
vector<int> g[5 * (10000) + 10];
int p[5 * (10000) + 10];
int ans[5 * (10000) + 10];
int v[5 * (10000) + 10];
void dfs(int s, int par) {
  v[s] = 1;
  ans[s] = par;
  for (auto i : g[s]) {
    if (v[i] != 1) {
      dfs(i, s);
    }
  }
}
int main() {
  cin >> n >> r1 >> r2;
  int var = 0;
  for (int i = 0; i < n - 1; i++) {
    if (i == r1 - 1) {
      g[var + 1].push_back(var + 1);
      var += 1;
    }
    cin >> tt;
    g[var + 1].push_back(tt);
    g[tt].push_back(var + 1);
    var++;
  }
  dfs(r2, -1);
  cout << " ";
  for (int i = 1; i < n + 1; i++) {
    if (i == r2) {
      continue;
    } else {
      cout << ans[i] << " ";
    }
  }
  cout << endl;
}
