#include <bits/stdc++.h>
using namespace std;
int n;
int par[50100];
vector<int> ed[50100];
int newp[50100];
bool vis[50100];
inline void dfs(int np, int p) {
  if (vis[np]) return;
  vis[np] = 1;
  newp[np] = p;
  for (int i = 0; i < (((int)(ed[np]).size())); i++) dfs(ed[np][i], np);
}
int main() {
  scanf("%d", &n);
  int r1, r2;
  scanf("%d%d", &r1, &r2);
  r1--;
  r2--;
  for (int i = 0; i < (n); i++) {
    if (i == r1) continue;
    scanf("%d", &par[i]);
    par[i]--;
    ed[par[i]].push_back(i);
    ed[i].push_back(par[i]);
  }
  dfs(r2, -1);
  vector<int> out;
  for (int i = 0; i < (n); i++) {
    if (i == r2) continue;
    out.push_back(newp[i] + 1);
  }
  for (int i = 0; i < (((int)(out).size())); i++)
    printf("%d%c", out[i], ((i == ((int)(out).size()) - 1) ? '\n' : ' '));
}
