#include <bits/stdc++.h>
using namespace std;
vector<int> v[1000001];
int ans[1000001];
void dfs(int cur, int par) {
  for (int i = 0; i < v[cur].size(); i++) {
    int x = v[cur][i];
    if (x == par) continue;
    ans[x] = cur;
    dfs(x, cur);
  }
}
int main() {
  ios::sync_with_stdio(false);
  int i, n, r1, r2, x, y;
  cin >> n >> r1 >> r2;
  for (i = 1; i <= n; i++) {
    if (i != r1) {
      cin >> x;
      v[i].push_back(x);
      v[x].push_back(i);
    }
  }
  dfs(r2, -1);
  for (i = 1; i <= n; i++) {
    if (i != r2) cout << ans[i] << " ";
  }
  return 0;
}
