#include <bits/stdc++.h>
using namespace std;
long long int vis[100000], ans[100000], n, r1, r2, i, a;
vector<long long int> gr[100000];
void dfs2(long long int s, long long int p) {
  vis[s] = 1;
  ans[s] = p;
  for (long long int i = 0; i < gr[s].size(); i++) {
    if (!vis[gr[s][i]]) dfs2(gr[s][i], s);
  }
}
bool dfs1(long long int s) {
  vis[s] = 1;
  if (s == r2) {
    memset(vis, 0, sizeof(vis));
    dfs2(r2, r2);
    return 1;
  }
  for (long long int i = 0; i < gr[s].size(); i++) {
    if (!vis[gr[s][i]]) {
      if (dfs1(gr[s][i])) return 1;
    }
  }
  return 0;
}
int main() {
  cin >> n >> r1 >> r2;
  for (i = 1; i <= n; i++) {
    if (i == r1) continue;
    cin >> a;
    gr[i].push_back(a);
    gr[a].push_back(i);
  }
  dfs1(r1);
  for (i = 1; i <= n; i++) {
    if (i == r2) continue;
    cout << ans[i] << " ";
  }
  return 0;
}
