#include <bits/stdc++.h>
using namespace std;
const int maxn = 50050;
vector<int> v[maxn];
int p[maxn];
bool mark[maxn];
void dfs(int u) {
  mark[u] = true;
  for (int i = 0; i < v[u].size(); i++)
    if (mark[v[u][i]] == false) {
      p[v[u][i]] = u;
      dfs(v[u][i]);
    }
}
int main() {
  int n, r1, r2;
  cin >> n >> r1 >> r2;
  for (int i = 1; i <= n; i++)
    if (i != r1) {
      int x;
      cin >> x;
      v[i].push_back(x);
      v[x].push_back(i);
    }
  dfs(r2);
  for (int i = 1; i <= n; i++)
    if (i != r2) cout << p[i] << " ";
  cout << endl;
  return 0;
}
