#include <bits/stdc++.h>
using namespace std;
const int maxn = 500005;
int pa[maxn];
vector<int> v[maxn];
void dfs(int now, int P) {
  for (int i = 0, l = v[now].size(); i < l; i++) {
    if (v[now][i] == P) continue;
    pa[v[now][i]] = now;
    dfs(v[now][i], now);
  }
}
int main() {
  int n, r1, r2;
  cin >> n >> r1 >> r2;
  for (int i = 1; i <= n; i++) {
    if (i == r1) continue;
    cin >> pa[i];
    v[pa[i]].push_back(i);
    v[i].push_back(pa[i]);
  }
  dfs(r2, -1);
  for (int i = 1; i <= n; i++) {
    if (i == r2) continue;
    cout << pa[i] << " ";
  }
  return 0;
}
