#include <bits/stdc++.h>
using namespace std;
int n, r1, r2;
vector<vector<int> > g(60000);
vector<int> dad(60000);
int i, j;
vector<bool> used(60000);
void dfs(int s, int d) {
  used[s] = true;
  dad[s] = d;
  for (vector<int>::iterator i = g[s].begin(); i != g[s].end(); ++i) {
    if (!used[*i]) dfs(*i, s);
  }
}
int main(int argc, char** argv) {
  cin >> n >> r1 >> r2;
  --r1, --r2;
  int a = 0;
  for (int i = 0; i < n; i++) {
    if (i == r1) continue;
    scanf("%d", &a);
    --a;
    g[a].push_back(i);
    g[i].push_back(a);
  }
  dfs(r2, -1);
  for (int i = 0; i < n; i++)
    if (dad[i] != -1) cout << dad[i] + 1 << " ";
  return 0;
}
