#include <bits/stdc++.h>
using namespace std;
int p[50001];
vector<int> child[50001];
bool visited[50001] = {false};
int n, oldC, newC;
int main() {
  cin >> n >> oldC >> newC;
  for (int i = 1; i < n; i++) {
    int tmp = i;
    if (tmp >= oldC) tmp++;
    scanf("%d", &p[tmp]);
    child[p[tmp]].push_back(tmp);
    child[tmp].push_back(p[tmp]);
  }
  queue<int> q;
  q.push(newC);
  visited[newC] = true;
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    vector<int> v = child[x];
    for (int i = 0; i < v.size(); i++) {
      if (!visited[v[i]]) {
        visited[v[i]] = true;
        q.push(v[i]);
        p[v[i]] = x;
      }
    }
  }
  for (int i = 1; i < n; i++) {
    int tmp = i;
    if (tmp >= newC) tmp++;
    printf("%d ", p[tmp]);
  }
  return 0;
}
