#include <bits/stdc++.h>
using namespace std;
const int N = 300011;
int n, arr[N], r1, r2, j;
bool vis[N];
vector<int> v[N];
void dfs(int x, int prv) {
  if (vis[x]) return;
  vis[x] = 1;
  if (x != prv) arr[x] = prv;
  for (auto u : v[x]) dfs(u, x);
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> r1 >> r2;
  arr[r1] = -1;
  for (int i = 1; i <= n - 1; i++) {
    j = i;
    if (i >= r1) j++;
    cin >> arr[j];
  }
  for (int i = 1; i <= n; i++) {
    if (arr[i] == -1) continue;
    v[i].push_back(arr[i]);
    v[arr[i]].push_back(i);
  }
  dfs(r2, r2);
  for (int i = 1; i <= n; i++)
    if (i != r2) cout << arr[i] << " ";
}
